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

Side by Side Diff: plugins/org.chromium.debug.ui/src/org/chromium/debug/ui/launcher/ChromiumRemoteTab.java

Issue 7398023: Redesign UI for accurateness property of file (Closed) Base URL: https://chromedevtools.googlecode.com/svn/trunk
Patch Set: Created 9 years, 5 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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.launcher; 5 package org.chromium.debug.ui.launcher;
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.Collection; 9 import java.util.Collection;
10 import java.util.Collections; 10 import java.util.Collections;
11 import java.util.LinkedHashMap; 11 import java.util.LinkedHashMap;
12 import java.util.List; 12 import java.util.List;
13 import java.util.Map; 13 import java.util.Map;
14 14
15 import org.chromium.debug.core.ChromiumDebugPlugin; 15 import org.chromium.debug.core.ChromiumDebugPlugin;
16 import org.chromium.debug.core.ChromiumSourceDirector; 16 import org.chromium.debug.core.ChromiumSourceDirector;
17 import org.chromium.debug.core.SourceNameMapperContainer; 17 import org.chromium.debug.core.SourceNameMapperContainer;
18 import org.chromium.debug.core.model.BreakpointSynchronizer.Direction; 18 import org.chromium.debug.core.model.BreakpointSynchronizer.Direction;
19 import org.chromium.debug.core.model.LaunchParams; 19 import org.chromium.debug.core.model.LaunchParams;
20 import org.chromium.debug.core.model.LaunchParams.LookupAccurateness; 20 import org.chromium.debug.core.model.LaunchParams.LookupMode;
21 import org.chromium.debug.core.model.LaunchParams.ValueConverter; 21 import org.chromium.debug.core.model.LaunchParams.ValueConverter;
22 import org.eclipse.core.runtime.CoreException; 22 import org.eclipse.core.runtime.CoreException;
23 import org.eclipse.debug.core.DebugPlugin; 23 import org.eclipse.debug.core.DebugPlugin;
24 import org.eclipse.debug.core.ILaunchConfiguration; 24 import org.eclipse.debug.core.ILaunchConfiguration;
25 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 25 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
26 import org.eclipse.debug.core.ILaunchManager; 26 import org.eclipse.debug.core.ILaunchManager;
27 import org.eclipse.debug.core.model.ISourceLocator; 27 import org.eclipse.debug.core.model.ISourceLocator;
28 import org.eclipse.debug.core.sourcelookup.IPersistableSourceLocator2; 28 import org.eclipse.debug.core.sourcelookup.IPersistableSourceLocator2;
29 import org.eclipse.debug.core.sourcelookup.ISourceContainer; 29 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
30 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; 30 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // However, recommended range is [1024, 32767]. 63 // However, recommended range is [1024, 32767].
64 private static final int minimumPortValue = 0; 64 private static final int minimumPortValue = 0;
65 private static final int maximumPortValue = 65535; 65 private static final int maximumPortValue = 65535;
66 66
67 private final SourceContainerChecker sourceContainerChecker = new SourceContai nerChecker(); 67 private final SourceContainerChecker sourceContainerChecker = new SourceContai nerChecker();
68 private final Params params; 68 private final Params params;
69 private TabElements tabElements = null; 69 private TabElements tabElements = null;
70 70
71 public static class Params { 71 public static class Params {
72 private final HostChecker hostChecker; 72 private final HostChecker hostChecker;
73 private final LookupAccurateness newConfigLookupAccurateness; 73 private final LookupMode newConfigLookupMode;
74 private final String scriptNameDescription; 74 private final String scriptNameDescription;
75 75
76 public Params(HostChecker hostChecker, 76 public Params(HostChecker hostChecker, LookupMode newConfigLookupMode,
77 LookupAccurateness newConfigLookupAccurateness,
78 String scriptNameDescription) { 77 String scriptNameDescription) {
79 this.hostChecker = hostChecker; 78 this.hostChecker = hostChecker;
80 this.newConfigLookupAccurateness = newConfigLookupAccurateness; 79 this.newConfigLookupMode = newConfigLookupMode;
81 this.scriptNameDescription = scriptNameDescription; 80 this.scriptNameDescription = scriptNameDescription;
82 } 81 }
83 82
84 HostChecker getHostChecker() { 83 HostChecker getHostChecker() {
85 return hostChecker; 84 return hostChecker;
86 } 85 }
87 86
88 LookupAccurateness getNewConfigLookupAccurateness() { 87 LookupMode getNewConfigLookupMode() {
89 return newConfigLookupAccurateness; 88 return newConfigLookupMode;
90 } 89 }
91 90
92 String getScriptNameDescription() { 91 String getScriptNameDescription() {
93 return scriptNameDescription; 92 return scriptNameDescription;
94 } 93 }
95 94
96 public static final Params CHROME = new Params(HostChecker.LOCAL_ONLY, 95 public static final Params CHROME = new Params(HostChecker.LOCAL_ONLY,
97 LaunchParams.LookupAccurateness.INACCURATE, "URL"); 96 LaunchParams.LookupMode.AUTO_DETECT, "URL");
98 97
99 public static final Params STANDALONE = new Params(null, 98 public static final Params STANDALONE = new Params(null,
100 LaunchParams.LookupAccurateness.INACCURATE, "plain file path"); 99 LaunchParams.LookupMode.AUTO_DETECT, "plain file path");
101 100
102 public static final Params WIP = new Params(HostChecker.LOCAL_ONLY, 101 public static final Params WIP = new Params(HostChecker.LOCAL_ONLY,
103 LaunchParams.LookupAccurateness.ACCURATE, "URL"); 102 LaunchParams.LookupMode.EXACT_MATCH, "URL");
104 } 103 }
105 104
106 /** 105 /**
107 * Possibly checks host property in config. 106 * Possibly checks host property in config.
108 */ 107 */
109 public static abstract class HostChecker { 108 public static abstract class HostChecker {
110 public abstract String getWarning(ILaunchConfiguration config) throws CoreEx ception; 109 public abstract String getWarning(ILaunchConfiguration config) throws CoreEx ception;
111 110
112 public static HostChecker LOCAL_ONLY = new HostChecker() { 111 public static HostChecker LOCAL_ONLY = new HostChecker() {
113 @Override 112 @Override
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 button.setLayoutData(gd); 195 button.setLayoutData(gd);
197 SWTFactory.setButtonDimensionHint(button); 196 SWTFactory.setButtonDimensionHint(button);
198 int index = buttonMap.size(); 197 int index = buttonMap.size();
199 buttonMap.put(index, button); 198 buttonMap.put(index, button);
200 } 199 }
201 200
202 breakpointRadioButtons = 201 breakpointRadioButtons =
203 new RadioButtonsLogic<Integer>(buttonMap, radioButtonsListener); 202 new RadioButtonsLogic<Integer>(buttonMap, radioButtonsListener);
204 } 203 }
205 204
206 InaccurateOptionControl inaccurateOptionControl = 205 LookupModeControl lookupModeControl =
207 new InaccurateOptionControl(composite, params.getScriptNameDescription() ); 206 new LookupModeControl(composite, params.getScriptNameDescription());
208 207
209 final RadioButtonsLogic<LookupAccurateness> inaccuratenessLogic = 208 final RadioButtonsLogic<LookupMode> lookupModeLogic =
210 inaccurateOptionControl.createLogic(radioButtonsListener); 209 lookupModeControl.createLogic(radioButtonsListener);
211 210
212 return new TabElements() { 211 return new TabElements() {
213 @Override public StringFieldEditor getHost() { 212 @Override public StringFieldEditor getHost() {
214 return debugHost; 213 return debugHost;
215 } 214 }
216 @Override public IntegerFieldEditor getPort() { 215 @Override public IntegerFieldEditor getPort() {
217 return debugPort; 216 return debugPort;
218 } 217 }
219 @Override public BooleanFieldEditor getAddNetworkConsole() { 218 @Override public BooleanFieldEditor getAddNetworkConsole() {
220 return addNetworkConsole; 219 return addNetworkConsole;
221 } 220 }
222 @Override public RadioButtonsLogic<Integer> getBreakpointRadioButtons() { 221 @Override public RadioButtonsLogic<Integer> getBreakpointRadioButtons() {
223 return breakpointRadioButtons; 222 return breakpointRadioButtons;
224 } 223 }
225 @Override public RadioButtonsLogic<LookupAccurateness> getAccuratenessCont rol() { 224 @Override public RadioButtonsLogic<LookupMode> getLookupMode() {
226 return inaccuratenessLogic; 225 return lookupModeLogic;
227 } 226 }
228 }; 227 };
229 } 228 }
230 229
231 public String getName() { 230 public String getName() {
232 return Messages.ChromiumRemoteTab_RemoteTabName; 231 return Messages.ChromiumRemoteTab_RemoteTabName;
233 } 232 }
234 233
235 public void initializeFrom(ILaunchConfiguration config) { 234 public void initializeFrom(ILaunchConfiguration config) {
236 for (TabField<?, ?> field : TAB_FIELDS) { 235 for (TabField<?, ?> field : TAB_FIELDS) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 408 }
410 button.addSelectionListener(selectionListener); 409 button.addSelectionListener(selectionListener);
411 } 410 }
412 } 411 }
413 412
414 private interface TabElements { 413 private interface TabElements {
415 StringFieldEditor getHost(); 414 StringFieldEditor getHost();
416 IntegerFieldEditor getPort(); 415 IntegerFieldEditor getPort();
417 BooleanFieldEditor getAddNetworkConsole(); 416 BooleanFieldEditor getAddNetworkConsole();
418 RadioButtonsLogic<Integer> getBreakpointRadioButtons(); 417 RadioButtonsLogic<Integer> getBreakpointRadioButtons();
419 RadioButtonsLogic<LookupAccurateness> getAccuratenessControl(); 418 RadioButtonsLogic<LookupMode> getLookupMode();
420 } 419 }
421 420
422 /** 421 /**
423 * A dialog window tab field description. It is a static description -- it has no reference to 422 * A dialog window tab field description. It is a static description -- it has no reference to
424 * a particular element instance. 423 * a particular element instance.
425 * @param <P> physical type of field as stored in config; used internally 424 * @param <P> physical type of field as stored in config; used internally
426 * @param <L> logical type of field used in runtime operations 425 * @param <L> logical type of field used in runtime operations
427 */ 426 */
428 private static class TabField<P, L> { 427 private static class TabField<P, L> {
429 private final String configAttributeName; 428 private final String configAttributeName;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 new DefaultsProvider<String>() { 654 new DefaultsProvider<String>() {
656 @Override String getFallbackValue() { 655 @Override String getFallbackValue() {
657 return Direction.MERGE.toString(); 656 return Direction.MERGE.toString();
658 } 657 }
659 @Override String getInitialConfigValue(ChromiumRemoteTab dialog) { 658 @Override String getInitialConfigValue(ChromiumRemoteTab dialog) {
660 return null; 659 return null;
661 } 660 }
662 }, 661 },
663 ValueConverter.<String>getTrivial())); 662 ValueConverter.<String>getTrivial()));
664 663
665 list.add(new TabField<String, LookupAccurateness>( 664 list.add(new TabField<String, LookupMode>(
666 LaunchParams.SOURCE_LOOKUP_ACCURATENESS, TypedMethods.STRING, 665 LaunchParams.SOURCE_LOOKUP_MODE, TypedMethods.STRING,
667 new FieldAccess<LookupAccurateness>() { 666 new FieldAccess<LookupMode>() {
668 @Override 667 @Override
669 void setValue(LookupAccurateness value, TabElements tabElements) { 668 void setValue(LookupMode value, TabElements tabElements) {
670 tabElements.getAccuratenessControl().select(value); 669 tabElements.getLookupMode().select(value);
671 } 670 }
672 @Override 671 @Override
673 LookupAccurateness getValue(TabElements tabElements) { 672 LookupMode getValue(TabElements tabElements) {
674 return tabElements.getAccuratenessControl().getSelected(); 673 return tabElements.getLookupMode().getSelected();
675 } 674 }
676 }, 675 },
677 new DefaultsProvider<LookupAccurateness>() { 676 new DefaultsProvider<LookupMode>() {
678 @Override LookupAccurateness getFallbackValue() { 677 @Override LookupMode getFallbackValue() {
679 // TODO: support default value from eclipse variables. 678 // TODO: support default value from eclipse variables.
680 return LookupAccurateness.DEFAULT_VALUE; 679 return LookupMode.DEFAULT_VALUE;
681 } 680 }
682 @Override LookupAccurateness getInitialConfigValue(ChromiumRemoteTab d ialog) { 681 @Override LookupMode getInitialConfigValue(ChromiumRemoteTab dialog) {
683 return dialog.params.getNewConfigLookupAccurateness(); 682 return dialog.params.getNewConfigLookupMode();
684 } 683 }
685 }, 684 },
686 LookupAccurateness.STRING_CONVERTER)); 685 LookupMode.STRING_CONVERTER));
687 686
688 TAB_FIELDS = Collections.unmodifiableList(list); 687 TAB_FIELDS = Collections.unmodifiableList(list);
689 } 688 }
690 689
691 private static class SourceContainerChecker { 690 private static class SourceContainerChecker {
692 public String check(ILaunchConfiguration config) { 691 public String check(ILaunchConfiguration config) {
693 LookupAccurateness accurateness; 692 LookupMode lookupMode;
694 try { 693 try {
695 accurateness = ChromiumSourceDirector.readLookupAccurateness(config); 694 lookupMode = ChromiumSourceDirector.readLookupMode(config);
696 } catch (CoreException e) { 695 } catch (CoreException e) {
697 ChromiumDebugPlugin.log(e); 696 ChromiumDebugPlugin.log(e);
698 return null; 697 return null;
699 } 698 }
700 if (accurateness != LookupAccurateness.INACCURATE) { 699 if (lookupMode != LookupMode.AUTO_DETECT) {
701 return null; 700 return null;
702 } 701 }
703 702
704 ISourceLookupDirector director; 703 ISourceLookupDirector director;
705 try { 704 try {
706 director = read(config); 705 director = read(config);
707 } catch (CoreException e) { 706 } catch (CoreException e) {
708 return null; 707 return null;
709 } 708 }
710 if (director == null) { 709 if (director == null) {
711 return null; 710 return null;
712 } 711 }
713 for (ISourceContainer sourceContainer : director.getSourceContainers()) { 712 for (ISourceContainer sourceContainer : director.getSourceContainers()) {
714 if (sourceContainer instanceof SourceNameMapperContainer) { 713 if (sourceContainer instanceof SourceNameMapperContainer) {
715 return Messages.ChromiumRemoteTab_INACCURATE_CONTAINER_WARNING; 714 return Messages.ChromiumRemoteTab_AUTO_DETECT_CONTAINER_WARNING;
716 } 715 }
717 } 716 }
718 return null; 717 return null;
719 } 718 }
720 719
721 private ISourceLookupDirector read(ILaunchConfiguration config) throws CoreE xception { 720 private ISourceLookupDirector read(ILaunchConfiguration config) throws CoreE xception {
722 String memento = config.getAttribute( 721 String memento = config.getAttribute(
723 ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null); 722 ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null);
724 if (memento == null) { 723 if (memento == null) {
725 return null; 724 return null;
(...skipping 16 matching lines...) Expand all
742 private static GridLayout createHtmlStyleGridLayout(int numberOfColumns) { 741 private static GridLayout createHtmlStyleGridLayout(int numberOfColumns) {
743 GridLayout layout = new GridLayout(numberOfColumns, false); 742 GridLayout layout = new GridLayout(numberOfColumns, false);
744 layout.horizontalSpacing = 0; 743 layout.horizontalSpacing = 0;
745 layout.verticalSpacing = 0; 744 layout.verticalSpacing = 0;
746 layout.marginWidth = 0; 745 layout.marginWidth = 0;
747 layout.marginHeight = 0; 746 layout.marginHeight = 0;
748 return layout; 747 return layout;
749 } 748 }
750 749
751 /** 750 /**
752 * Dialog UI group of 2 radio buttons for lookup accurateness mode. 751 * Dialog UI group of 2 radio buttons for lookup mode.
753 */ 752 */
754 private static class InaccurateOptionControl { 753 private static class LookupModeControl {
755 private final Map<LookupAccurateness, Button> buttons; 754 private final Map<LookupMode, Button> buttons;
756 InaccurateOptionControl(Composite container, String scriptNameFormatDescript ion) { 755 LookupModeControl(Composite container, String scriptNameFormatDescription) {
757 buttons = new LinkedHashMap<LookupAccurateness, Button>(); 756 buttons = new LinkedHashMap<LookupMode, Button>();
758 Group breakpointGroup = new Group(container, 0); 757 Group breakpointGroup = new Group(container, 0);
759 breakpointGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 758 breakpointGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
760 breakpointGroup.setText("Source look-up method for workspace files"); 759 breakpointGroup.setText("Source look-up method for workspace files");
761 breakpointGroup.setLayout(new GridLayout(1, false)); 760 breakpointGroup.setLayout(new GridLayout(1, false));
762 761
763 buttons.put(LookupAccurateness.ACCURATE, createButtonBlock(breakpointGroup , 762 buttons.put(LookupMode.EXACT_MATCH, createButtonBlock(breakpointGroup,
764 "Accurate", "Full script names are used.", 763 "Exact match", "Full script names are used.",
765 "JavaScript Source Name Mapper must be set up in Source tab.")); 764 "JavaScript Source Name Mapper must be set up in Source tab."));
766 buttons.put(LookupAccurateness.INACCURATE, createButtonBlock(breakpointGro up, 765
767 "Inaccurate", "Only short file names are used.", 766 buttons.put(LookupMode.AUTO_DETECT, createButtonBlock(breakpointGroup,
768 "Actual script names are treated as: " + scriptNameFormatDescription)) ; 767 "Auto-detect", "Only short file names are used.",
768 "Actual script names are parsed as: " + scriptNameFormatDescription));
769 769
770 addRadioButtonSwitcher(buttons.values()); 770 addRadioButtonSwitcher(buttons.values());
771 } 771 }
772 772
773 RadioButtonsLogic<LookupAccurateness> createLogic(RadioButtonsLogic.Listener listener) { 773 RadioButtonsLogic<LookupMode> createLogic(RadioButtonsLogic.Listener listene r) {
774 return new RadioButtonsLogic<LookupAccurateness>(buttons, listener); 774 return new RadioButtonsLogic<LookupMode>(buttons, listener);
775 } 775 }
776 776
777 private static Button createButtonBlock(Composite parent, String buttonLabel , 777 private static Button createButtonBlock(Composite parent, String buttonLabel ,
778 String descriptionLine1, String descriptionLine2) { 778 String descriptionLine1, String descriptionLine2) {
779 Composite buttonComposite = new Composite(parent, SWT.NONE); 779 Composite buttonComposite = new Composite(parent, SWT.NONE);
780 GridLayout gridLayout = createHtmlStyleGridLayout(2); 780 GridLayout gridLayout = createHtmlStyleGridLayout(3);
781 buttonComposite.setLayout(gridLayout); 781 buttonComposite.setLayout(gridLayout);
782 Button button = new Button(buttonComposite, SWT.RADIO | SWT.NO_RADIO_GROUP ); 782 Button button = new Button(buttonComposite, SWT.RADIO | SWT.NO_RADIO_GROUP );
783 button.setText(buttonLabel + " "); 783 button.setText(buttonLabel);
784 Label padding = new Label(buttonComposite, SWT.NONE);
785 padding.setText(" ");
784 Label descriptionLine1Label = new Label(buttonComposite, SWT.NONE); 786 Label descriptionLine1Label = new Label(buttonComposite, SWT.NONE);
785 descriptionLine1Label.setText(descriptionLine1); 787 descriptionLine1Label.setText(descriptionLine1);
786 // Extra label to fill a grid in layout. 788 // Extra label to fill a grid in layout.
787 new Label(buttonComposite, SWT.NONE); 789 new Label(buttonComposite, SWT.NONE);
790 new Label(buttonComposite, SWT.NONE);
788 Label descriptionLine2Label = new Label(buttonComposite, SWT.NONE); 791 Label descriptionLine2Label = new Label(buttonComposite, SWT.NONE);
789 descriptionLine2Label.setText(descriptionLine2); 792 descriptionLine2Label.setText(descriptionLine2);
790 return button; 793 return button;
791 } 794 }
792 } 795 }
793 } 796 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698