Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: plugins/org.chromium.debug.ui/src/org/chromium/debug/ui/liveedit/PushChangesWizard.java

Issue 12040008: Disaply compile error position in editor (Closed) Base URL: https://chromedevtools.googlecode.com/svn/trunk
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 java.util.ArrayList; 7 import java.util.ArrayList;
8 import java.util.Arrays; 8 import java.util.Arrays;
9 import java.util.List; 9 import java.util.List;
10 10
11 import org.chromium.debug.core.model.PushChangesPlan; 11 import org.chromium.debug.core.model.PushChangesPlan;
12 import org.chromium.debug.core.util.ScriptTargetMapping; 12 import org.chromium.debug.core.util.ScriptTargetMapping;
13 import org.chromium.debug.ui.WizardUtils.LogicBasedWizard; 13 import org.chromium.debug.ui.WizardUtils.LogicBasedWizard;
14 import org.chromium.debug.ui.WizardUtils.PageElements; 14 import org.chromium.debug.ui.WizardUtils.PageElements;
15 import org.chromium.debug.ui.WizardUtils.PageElementsFactory; 15 import org.chromium.debug.ui.WizardUtils.PageElementsFactory;
16 import org.chromium.debug.ui.WizardUtils.PageImpl; 16 import org.chromium.debug.ui.WizardUtils.PageImpl;
17 import org.chromium.debug.ui.WizardUtils.WizardFinisher; 17 import org.chromium.debug.ui.WizardUtils.WizardFinisher;
18 import org.chromium.debug.ui.WizardUtils.WizardLogic; 18 import org.chromium.debug.ui.WizardUtils.WizardLogic;
19 import org.chromium.debug.ui.WizardUtils.WizardPageSet; 19 import org.chromium.debug.ui.WizardUtils.WizardPageSet;
20 import org.chromium.debug.ui.actions.ChooseVmControl; 20 import org.chromium.debug.ui.actions.ChooseVmControl;
21 import org.chromium.debug.ui.liveedit.LiveEditResultDialog.ErrorPositionHighligh ter;
21 import org.chromium.debug.ui.liveedit.LiveEditResultDialog.Input; 22 import org.chromium.debug.ui.liveedit.LiveEditResultDialog.Input;
22 import org.chromium.debug.ui.liveedit.LiveEditResultDialog.SingleInput; 23 import org.chromium.debug.ui.liveedit.LiveEditResultDialog.SingleInput;
23 import org.chromium.sdk.CallbackSemaphore; 24 import org.chromium.sdk.CallbackSemaphore;
24 import org.chromium.sdk.RelayOk; 25 import org.chromium.sdk.RelayOk;
25 import org.chromium.sdk.UpdatableScript; 26 import org.chromium.sdk.UpdatableScript;
26 import org.eclipse.core.runtime.IProgressMonitor; 27 import org.eclipse.core.runtime.IProgressMonitor;
27 import org.eclipse.core.runtime.SubProgressMonitor; 28 import org.eclipse.core.runtime.SubProgressMonitor;
28 import org.eclipse.jface.wizard.IWizard; 29 import org.eclipse.jface.wizard.IWizard;
29 import org.eclipse.jface.wizard.WizardDialog; 30 import org.eclipse.jface.wizard.WizardDialog;
30 import org.eclipse.osgi.util.NLS; 31 import org.eclipse.osgi.util.NLS;
31 import org.eclipse.swt.SWT; 32 import org.eclipse.swt.SWT;
32 import org.eclipse.swt.layout.GridData; 33 import org.eclipse.swt.layout.GridData;
33 import org.eclipse.swt.layout.GridLayout; 34 import org.eclipse.swt.layout.GridLayout;
34 import org.eclipse.swt.widgets.Composite; 35 import org.eclipse.swt.widgets.Composite;
35 import org.eclipse.swt.widgets.Control; 36 import org.eclipse.swt.widgets.Control;
36 import org.eclipse.swt.widgets.Label; 37 import org.eclipse.swt.widgets.Label;
37 import org.eclipse.swt.widgets.Shell; 38 import org.eclipse.swt.widgets.Shell;
38 39
39 40
40 /** 41 /**
41 * A wizard that pushes script changes to V8 VM (LiveEdit); it also lets user ch oose target VM(s), 42 * A wizard that pushes script changes to V8 VM (LiveEdit); it also lets user ch oose target VM(s),
42 * review changes in script text, review which function will be patched. 43 * review changes in script text, review which function will be patched.
43 */ 44 */
44 public class PushChangesWizard { 45 public class PushChangesWizard {
45 46
46 public static void start(final List<? extends ScriptTargetMapping> filePairs, Shell shell) { 47 public static void start(final List<? extends ScriptTargetMapping> filePairs, Shell shell,
48 final ErrorPositionHighlighter positionHighlighter) {
47 // Create pages. 49 // Create pages.
48 final PageImpl<ChooseVmPageElements> chooseVmPage = new PageImpl<ChooseVmPag eElements>( 50 final PageImpl<ChooseVmPageElements> chooseVmPage = new PageImpl<ChooseVmPag eElements>(
49 "choose VM", //$NON-NLS-1$ 51 "choose VM", //$NON-NLS-1$
50 CHOOSE_VM_PAGE_FACTORY, 52 CHOOSE_VM_PAGE_FACTORY,
51 Messages.PushChangesWizard_CHOOSE_VM, 53 Messages.PushChangesWizard_CHOOSE_VM,
52 Messages.PushChangesWizard_CHOOSE_VM_DESCRIPTION); 54 Messages.PushChangesWizard_CHOOSE_VM_DESCRIPTION);
53 55
54 final PageImpl<V8PreviewPageElements> v8PreviewPage = new PageImpl<V8Preview PageElements>( 56 final PageImpl<V8PreviewPageElements> v8PreviewPage = new PageImpl<V8Preview PageElements>(
55 "v8 preview", //$NON-NLS-1$ 57 "v8 preview", //$NON-NLS-1$
56 V8_PREVIEW_PAGE_FACTORY, 58 V8_PREVIEW_PAGE_FACTORY,
(...skipping 14 matching lines...) Expand all
71 return chooseVmPage; 73 return chooseVmPage;
72 } 74 }
73 public PageImpl<V8PreviewPageElements> getV8PreviewPage() { 75 public PageImpl<V8PreviewPageElements> getV8PreviewPage() {
74 return v8PreviewPage; 76 return v8PreviewPage;
75 } 77 }
76 public PageImpl<PageElements> getMultipleVmStubPage() { 78 public PageImpl<PageElements> getMultipleVmStubPage() {
77 return multipleVmStubPage; 79 return multipleVmStubPage;
78 } 80 }
79 public WizardLogic createLogic(final LogicBasedWizard wizardImpl) { 81 public WizardLogic createLogic(final LogicBasedWizard wizardImpl) {
80 WizardLogicBuilder logicBuilder = new WizardLogicBuilder(this, wizardImp l); 82 WizardLogicBuilder logicBuilder = new WizardLogicBuilder(this, wizardImp l);
81 return logicBuilder.create(filePairs); 83 return logicBuilder.create(filePairs, positionHighlighter);
82 } 84 }
83 }; 85 };
84 86
85 // Start wizard engine. 87 // Start wizard engine.
86 LogicBasedWizard wizard = new LogicBasedWizard(pageSet); 88 LogicBasedWizard wizard = new LogicBasedWizard(pageSet);
87 wizard.setWindowTitle(Messages.PushChangesWizard_TITLE); 89 wizard.setWindowTitle(Messages.PushChangesWizard_TITLE);
88 WizardDialog wizardDialog = new WizardDialog(shell, wizard); 90 WizardDialog wizardDialog = new WizardDialog(shell, wizard);
89 wizardDialog.open(); 91 wizardDialog.open();
90 } 92 }
91 93
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 }; 171 };
170 } 172 }
171 }; 173 };
172 174
173 interface FinisherDelegate { 175 interface FinisherDelegate {
174 LiveEditResultDialog.Input run(IProgressMonitor monitor); 176 LiveEditResultDialog.Input run(IProgressMonitor monitor);
175 } 177 }
176 178
177 static class FinisherImpl implements WizardFinisher { 179 static class FinisherImpl implements WizardFinisher {
178 private final FinisherDelegate delegate; 180 private final FinisherDelegate delegate;
179 FinisherImpl(FinisherDelegate delegate) { 181 private final ErrorPositionHighlighter positionHighlighter;
182 FinisherImpl(FinisherDelegate delegate, ErrorPositionHighlighter positionHig hlighter) {
180 this.delegate = delegate; 183 this.delegate = delegate;
184 this.positionHighlighter = positionHighlighter;
181 } 185 }
182 public boolean performFinish(IWizard wizard, IProgressMonitor monitor) { 186 public boolean performFinish(IWizard wizard, IProgressMonitor monitor) {
183 LiveEditResultDialog.Input dialogInput = delegate.run(monitor); 187 LiveEditResultDialog.Input dialogInput = delegate.run(monitor);
184 LiveEditResultDialog dialog = 188 LiveEditResultDialog dialog = new LiveEditResultDialog(wizard.getContainer ().getShell(),
185 new LiveEditResultDialog(wizard.getContainer().getShell(), dialogInput ); 189 dialogInput, positionHighlighter);
186 dialog.open(); 190 dialog.open();
187 return true; 191 return true;
188 } 192 }
189 } 193 }
190 194
191 /** 195 /**
192 * A callback that gets called when user presses 'finish' and a single VM is s elected. 196 * A callback that gets called when user presses 'finish' and a single VM is s elected.
193 */ 197 */
194 static class SingleVmFinisher implements FinisherDelegate { 198 static class SingleVmFinisher implements FinisherDelegate {
195 private final PushChangesPlan pushChangesPlan; 199 private final PushChangesPlan pushChangesPlan;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 /** 248 /**
245 * Performs update to a VM and returns result in form of dialog window input. 249 * Performs update to a VM and returns result in form of dialog window input.
246 */ 250 */
247 private static LiveEditResultDialog.SingleInput performSingleVmUpdate( 251 private static LiveEditResultDialog.SingleInput performSingleVmUpdate(
248 final PushChangesPlan changesPlan, IProgressMonitor monitor) { 252 final PushChangesPlan changesPlan, IProgressMonitor monitor) {
249 final LiveEditResultDialog.SingleInput[] input = { null }; 253 final LiveEditResultDialog.SingleInput[] input = { null };
250 254
251 UpdatableScript.UpdateCallback callback = new UpdatableScript.UpdateCallback () { 255 UpdatableScript.UpdateCallback callback = new UpdatableScript.UpdateCallback () {
252 public void failure(String message, UpdatableScript.Failure failure) { 256 public void failure(String message, UpdatableScript.Failure failure) {
253 String text = NLS.bind("Failure: {0}", message); 257 String text = NLS.bind("Failure: {0}", message);
254 input[0] = LiveEditResultDialog.createTextInput(text, changesPlan); 258 input[0] = LiveEditResultDialog.createTextInput(text, changesPlan,
259 failure);
255 } 260 }
256 public void success(Object report, 261 public void success(Object report,
257 final UpdatableScript.ChangeDescription changeDescription) { 262 final UpdatableScript.ChangeDescription changeDescription) {
258 if (changeDescription == null) { 263 if (changeDescription == null) {
259 input[0] = LiveEditResultDialog.createTextInput( 264 input[0] = LiveEditResultDialog.createTextInput(
260 Messages.PushChangesWizard_EMPTY_CHANGE, changesPlan); 265 Messages.PushChangesWizard_EMPTY_CHANGE, changesPlan);
261 } else { 266 } else {
262 final String oldScriptName = changeDescription.getCreatedScriptName(); 267 final String oldScriptName = changeDescription.getCreatedScriptName();
263 final LiveEditResultDialog.OldScriptData oldScriptData; 268 final LiveEditResultDialog.OldScriptData oldScriptData;
264 if (oldScriptName == null) { 269 if (oldScriptName == null) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 306
302 CallbackSemaphore syncCallback = new CallbackSemaphore(); 307 CallbackSemaphore syncCallback = new CallbackSemaphore();
303 RelayOk relayOk = changesPlan.execute(false, callback, syncCallback); 308 RelayOk relayOk = changesPlan.execute(false, callback, syncCallback);
304 syncCallback.acquireDefault(relayOk); 309 syncCallback.acquireDefault(relayOk);
305 310
306 monitor.done(); 311 monitor.done();
307 312
308 return input[0]; 313 return input[0];
309 } 314 }
310 } 315 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698