Changeset 1180
- Timestamp:
- 05/27/08 08:07:44 (8 months ago)
- Files:
-
- trunk/descent.building/src/descent/building/IDescentBuilderConstants.java (modified) (1 diff)
- trunk/descent.building/src/descent/building/compiler/BooleanOption.java (modified) (1 diff)
- trunk/descent.building/src/descent/building/compiler/CompilerOption.java (modified) (3 diffs)
- trunk/descent.building/src/descent/building/compiler/EnumOption.java (modified) (1 diff)
- trunk/descent.building/src/descent/building/compiler/StringOption.java (modified) (1 diff)
- trunk/descent.building/src/descent/internal/building/compiler/DmdCompilerInterface.java (modified) (3 diffs)
- trunk/descent.building/src/descent/internal/building/compiler/IDmdCompilerConstants.java (added)
- trunk/descent.building/src/descent/internal/building/ui/CompilerTab.java (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/descent.building/src/descent/building/IDescentBuilderConstants.java
r1175 r1180 82 82 public static final String ATTR_OUTPUT_FILE = "descent.building.debuild.output_file"; 83 83 84 // TODO comment 85 public static final String ATTR_ADD_UNITTESTS = "descent.building.debuild.add_unittests"; 86 public static final String ATTR_DISABLE_ASSERTS = "descent.building.debuild.disable_asserts"; 87 public static final String ATTR_ADD_DEBUG_INFO = "descent.building.debuild.add_debug_info"; 88 public static final String ATTR_INSTRUMENT_FOR_COVERAGE = "descent.building.debuild.instrument_for_coverage"; 89 public static final String ATTR_INSTRUMENT_FOR_PROFILE = "descent.building.debuild.instrument_for_profile"; 90 84 91 /** 85 92 * Constant used for {@link #ATTR_OUTPUT_TYPE} to specify the output target trunk/descent.building/src/descent/building/compiler/BooleanOption.java
r1177 r1180 7 7 8 8 public BooleanOption(String attributeId, boolean defaultValue, 9 String label, String groupLabel, String onText, String offText) 9 String label, String groupLabel, String onText, String offText, 10 String helpText) 10 11 { 11 super(attributeId, defaultValue ? "true" : "false", label, groupLabel );12 super(attributeId, defaultValue ? "true" : "false", label, groupLabel, helpText); 12 13 this.onText = onText; 13 14 this.offText = offText; trunk/descent.building/src/descent/building/compiler/CompilerOption.java
r1177 r1180 7 7 private final String label; 8 8 private final String groupLabel; 9 private final String helpText; 9 10 10 11 public CompilerOption(String attributeId, String defaultValue, String label, 11 String groupLabel )12 String groupLabel, String helpText) 12 13 { 13 14 this.attributeId = attributeId; … … 15 16 this.label = label; 16 17 this.groupLabel = groupLabel; 18 this.helpText = helpText; 17 19 } 18 20 … … 36 38 return groupLabel; 37 39 } 40 41 public final String getHelpText() 42 { 43 return helpText; 44 } 38 45 } trunk/descent.building/src/descent/building/compiler/EnumOption.java
r1177 r1180 9 9 public EnumOption(String attributeId, String defaultValue, 10 10 String label, String groupLabel, String[] optionValues, 11 String[] optionEditLabels )11 String[] optionEditLabels, String helpText) 12 12 { 13 13 this(attributeId, defaultValue, label, groupLabel, 14 optionValues, optionEditLabels, null );14 optionValues, optionEditLabels, null, helpText); 15 15 } 16 16 17 17 public EnumOption(String attributeId, String defaultValue, 18 18 String label, String groupLabel, String[] optionValues, 19 String[] optionEditLabels, String[] optionViewLabels) 19 String[] optionEditLabels, String[] optionViewLabels, 20 String helpText) 20 21 { 21 super(attributeId, defaultValue, label, groupLabel );22 super(attributeId, defaultValue, label, groupLabel, helpText); 22 23 this.optionValues = optionValues; 23 24 this.optionEditLabels = optionEditLabels; trunk/descent.building/src/descent/building/compiler/StringOption.java
r1177 r1180 4 4 { 5 5 public StringOption(String attributeId, String defaultValue, 6 String label, String groupLabel )6 String label, String groupLabel, String helpText) 7 7 { 8 super(attributeId, defaultValue, label, groupLabel );8 super(attributeId, defaultValue, label, groupLabel, helpText); 9 9 } 10 10 } trunk/descent.building/src/descent/internal/building/compiler/DmdCompilerInterface.java
r1177 r1180 13 13 import descent.building.compiler.IResponseInterpreter; 14 14 import descent.building.compiler.BuildResponse; 15 16 import static descent.building.IDescentBuilderConstants.*; 17 import static descent.internal.building.compiler.IDmdCompilerConstants.*; 15 18 16 19 public class DmdCompilerInterface implements ICompilerInterface … … 260 263 static 261 264 { 262 final String GROUP_FEATURES; 265 final String GROUP_FEATURES = "Features"; 266 final String GROUP_WARNINGS = "Warnings"; 267 final String GROUP_OPTIMIZATION = "Optimization"; 263 268 269 // TODO file options for header & doc generation 264 270 uiOptions = new CompilerOption[] 265 { 271 { 266 272 //------------------------------------------------------------------ 267 273 // Features 268 274 275 new BooleanOption( 276 ATTR_ADD_DEBUG_INFO, 277 true, 278 "Add debugging symbols", 279 GROUP_FEATURES, 280 "-g", 281 "", 282 "Adds debugging symbols. These make the generated objects " + 283 "slightly larger but is needed to use a debugger with the " + 284 "program."), 285 286 new BooleanOption( 287 ATTR_DISABLE_ASSERTS, 288 false, 289 "Release mode (disable asserts & contracts)", 290 GROUP_FEATURES, 291 "-release", 292 "", 293 "Turns off assert() statements in the code, in {} and out {} " + 294 "blocks on functions, and checking for array bounds errors. This " + 295 "makes the code run faster, so is a good choice for releasing the " + 296 "application, but are often useful for development."), 297 298 299 new BooleanOption( 300 ATTR_ADD_UNITTESTS, 301 false, 302 "Add unit tests", 303 GROUP_FEATURES, 304 "-unittest", 305 "", 306 "Adds code so that unittest {} blocks in your code are run before " + 307 "the program launches and enables version(unitttest) {} blocks."), 308 309 new BooleanOption( 310 ATTR_INSTRUMENT_FOR_COVERAGE, 311 false, 312 "Instrument for coverage analysis", 313 GROUP_FEATURES, 314 "-cov", 315 "", 316 "Adds code to the generated objects so that they will generate " + 317 "a file containing code coverage information after the program " + 318 "has been run. This is useful for seeing if unit tests execute " + 319 "all paths in your code."), 320 321 new BooleanOption( 322 ATTR_INSTRUMENT_FOR_PROFILE, 323 false, 324 "Instrument for profiling", 325 GROUP_FEATURES, 326 "-profile", 327 "", 328 "Adds code to the generated objects so they can be prodiled. " + 329 "This helps find bottlenecks that could be slowing down your " + 330 "application."), 331 332 //------------------------------------------------------------------ 333 // Warnings 334 335 new BooleanOption( 336 ATTR_ALLOW_DEPRECATED, 337 true, 338 "Allow deprecated code", 339 GROUP_WARNINGS, 340 "-d", 341 "", 342 "Allows code marked with the \"deprecated\" tags to be included " + 343 "in your program."), 344 345 new BooleanOption( 346 ATTR_SHOW_WARNINGS, 347 false, 348 "Show warnings", 349 GROUP_WARNINGS, 350 "-w", 351 "", 352 "Adds warnings for potentially unsafe or error-prone code. In " + 353 "DMD, if warnings are encountered, the program will not be " + 354 "compiled."), 355 356 357 //------------------------------------------------------------------ 358 // Optimization 359 360 new BooleanOption( 361 ATTR_OPTIMIZE_CODE, 362 false, 363 "Optimize code", 364 GROUP_OPTIMIZATION, 365 "-O", 366 "", 367 "Optimizes the generated code for best efficiency."), 368 369 new BooleanOption( 370 ATTR_INLINE_CODE, 371 false, 372 "Inline functions", 373 GROUP_OPTIMIZATION, 374 "-inline", 375 "", 376 "Allows inlining of short functions for increased code efficiency. " + 377 "This may cause issues with some debuggers."), 378 379 new BooleanOption( 380 ATTR_NOFLOAT, 381 false, 382 "Don't generate __fltused reference", 383 GROUP_OPTIMIZATION, 384 "-nofloat", 385 "", 386 "Prevents the emission of the __fltused reference in object files, " + 387 "even if floating point code is present. This is useful in library " + 388 "files."), 269 389 }; 270 390 } … … 307 427 public CompilerOption[] getOptions() 308 428 { 309 // TODO Auto-generated method stub310 429 return uiOptions; 311 430 } trunk/descent.building/src/descent/internal/building/ui/CompilerTab.java
r1177 r1180 16 16 import org.eclipse.jface.viewers.ComboBoxCellEditor; 17 17 import org.eclipse.jface.viewers.EditingSupport; 18 import org.eclipse.jface.viewers.ISelectionChangedListener; 18 19 import org.eclipse.jface.viewers.ITreeContentProvider; 20 import org.eclipse.jface.viewers.ITreeSelection; 21 import org.eclipse.jface.viewers.SelectionChangedEvent; 19 22 import org.eclipse.jface.viewers.TextCellEditor; 23 import org.eclipse.jface.viewers.TreePath; 20 24 import org.eclipse.jface.viewers.TreeViewer; 21 25 import org.eclipse.jface.viewers.TreeViewerColumn; … … 32 36 import org.eclipse.swt.widgets.Combo; 33 37 import org.eclipse.swt.widgets.Composite; 38 import org.eclipse.swt.widgets.Group; 39 import org.eclipse.swt.widgets.Label; 34 40 import org.eclipse.swt.widgets.Layout; 35 41 import org.eclipse.swt.widgets.Link; … … 64 70 comp = new Composite(comp, SWT.NONE); 65 71 GridData gd = new GridData(GridData.FILL_HORIZONTAL); 66 gd.horizontalSpan = 1;72 gd.horizontalSpan = 2; 67 73 comp.setLayoutData(gd); 68 74 GridLayout layout = new GridLayout(); … … 76 82 "configurations."); 77 83 gd = new GridData(GridData.FILL_BOTH); 78 gd.horizontalSpan = 1;84 gd.horizontalSpan = 2; 79 85 fHelpText.setLayoutData(gd); 80 86 fHelpText.addSelectionListener(new SelectionAdapter() … … 243 249 public abstract void setValue(Object value); 244 250 public abstract String getText(); 251 public abstract void initializeTo(String value); 252 public abstract void applyTo(ILaunchConfigurationWorkingCopy config); 245 253 } 246 254 … … 288 296 return selected ? option.getOnText() : option.getOffText(); 289 297 } 298 299 @Override 300 public void initializeTo(String value) 301 { 302 selected = Boolean.valueOf(value); 303 } 304 305 @Override 306 public void applyTo(ILaunchConfigurationWorkingCopy config) 307 { 308 config.setAttribute(option.getAttributeId(), 309 selected ? "true" : "false"); 310 } 290 311 } 291 312 … … 335 356 { 336 357 return option.getOptionViewLabels()[selected]; 358 } 359 360 @Override 361 public void initializeTo(String value) 362 { 363 String[] optionValues = option.getOptionValues(); 364 for(int i = 0; i < optionValues.length; i++) 365 { 366 if(optionValues[i].equals(i)) 367 { 368 selected = Integer.valueOf(i); 369 return; 370 } 371 } 372 } 373 374 @Override 375 public void applyTo(ILaunchConfigurationWorkingCopy config) 376 { 377 config.setAttribute(getOption().getAttributeId(), 378 option.getOptionValues()[selected.intValue()]); 337 379 } 338 380 } … … 380 422 { 381 423 selected = (String) value; 424 } 425 426 @Override 427 public void initializeTo(String value) 428 { 429 selected = value; 430 } 431 432 @Override 433 public void applyTo(ILaunchConfigurationWorkingCopy config) 434 { 435 config.setAttribute(getOption().getAttributeId(), selected); 382 436 } 383 437 } … … 435 489 Object newInput) 436 490 { 437 // T ODO491 // This is handled externally 438 492 } 439 493 } … … 442 496 private TreeViewer fViewer; 443 497 private TreeEntry[] fEntries; 498 private Group fHelpGroup; 499 private Label fHelpText; 444 500 445 501 public void addToControl(Composite comp) 446 502 { 447 fEntries = getTree();503 initializeTree(); 448 504 449 505 fViewer = new TreeViewer(comp, SWT.BORDER | SWT.FULL_SELECTION); 506 fViewer.setContentProvider(new OptionsContentProvider()); 450 507 fViewer.getTree().setHeaderVisible(true); 451 508 fViewer.getTree().setLinesVisible(true); … … 456 513 457 514 TreeViewerColumn column = new TreeViewerColumn(fViewer, SWT.NONE); 458 column.getColumn().setWidth(2 00);515 column.getColumn().setWidth(250); 459 516 column.getColumn().setText("Option"); 460 517 column.setLabelProvider(new ColumnLabelProvider() … … 530 587 531 588 GridData gd = new GridData(GridData.FILL_BOTH); 589 gd.horizontalSpan = 1; 532 590 fViewer.getControl().setLayoutData(gd); 533 591 534 fViewer.setContentProvider(new OptionsContentProvider()); 535 } 536 537 private TreeEntry[] getTree() 538 { 592 fHelpGroup = new Group(comp, SWT.SHADOW_IN); 593 gd = new GridData(GridData.FILL_VERTICAL); 594 gd.horizontalSpan = 1; 595 gd.widthHint = 200; // PERHAPS use PixelConverter or something...? 596 fHelpGroup.setLayoutData(gd); 597 598 GridLayout groupLayout = new GridLayout(); 599 groupLayout.numColumns = 1; 600 fHelpGroup.setLayout(groupLayout); 601 602 fHelpText = new Label(fHelpGroup, SWT.LEFT | SWT.WRAP); 603 gd = new GridData(GridData.FILL_BOTH); 604 gd.horizontalSpan = 1; 605 fHelpText.setText(""); 606 fHelpText.setLayoutData(gd); 607 608 fViewer.addSelectionChangedListener(new ISelectionChangedListener() 609 { 610 public void selectionChanged(SelectionChangedEvent event) 611 { 612 TreePath[] paths = ((ITreeSelection) fViewer.getSelection()).getPaths(); 613 if(0 == paths.length) 614 { 615 fHelpText.setText(""); 616 fHelpText.update(); 617 return; 618 } 619 620 Object selected = paths[0].getLastSegment(); 621 if(!(selected instanceof CompilerUIOption)) 622 { 623 fHelpText.setText(""); 624 fHelpText.update(); 625 return; 626 } 627 628 fHelpText.setText(((CompilerUIOption) selected).getOption(). 629 getHelpText()); 630 fHelpText.update(); 631 } 632 }); 633 634 fViewer.setInput(this); 635 fViewer.expandAll(); 636 } 637 638 private void initializeTree() 639 { 640 if(null != fEntries) 641 return; 642 539 643 ICompilerInterface compilerInterface = 540 644 getCompilerInterface(fSelectedCompiler); … … 545 649 { 546 650 String group = opt.getGroupLabel(); 547 if(!groups.containsKey(group)) ;651 if(!groups.containsKey(group)) 548 652 groups.put(group, new ArrayList<CompilerUIOption>()); 549 653 groups.get(group).add(toUIOption(opt)); 550 654 } 551 655 552 TreeEntry[] entries = new TreeEntry[groups.size()];656 fEntries = new TreeEntry[groups.size()]; 553 657 int i = 0; 554 658 for(String group : groups.keySet()) 555 659 { 556 660 List<CompilerUIOption> list = groups.get(group); 557 entries[i] = new TreeEntry(group,661 fEntries[i] = new TreeEntry(group, 558 662 list.toArray(new CompilerUIOption[list.size()])); 559 663 i++; 560 664 } 561 562 return entries;563 665 } 564 666 … … 588 690 fSelectedCompiler = compiler; 589 691 if(null != fViewer && null != fSelectedCompiler) 590 fViewer.setInput(fSelectedCompiler); 692 { 693 // TODO 694 } 591 695 } 592 696 593 697 public void initializeFrom(ILaunchConfiguration config) 594 698 { 595 // TODO Auto-generated method stub 699 initializeTree(); 700 for(TreeEntry group : fEntries) 701 { 702 for(CompilerUIOption uiOpt : group.children) 703 { 704 CompilerOption opt = uiOpt.getOption(); 705 String defaultValue = opt.getDefaultValue(); 706 String value = defaultValue; 707 try 708 { 709 value = config.getAttribute(opt.getAttributeId(), defaultValue); 710 } 711 catch(CoreException e) { } 712 uiOpt.initializeTo(value); 713 fViewer.update(uiOpt, null); 714 } 715 } 596 716 } 597 717 598 718 public void performApply(ILaunchConfigurationWorkingCopy config) 599 719 { 600 // TODO Auto-generated method stub 720 initializeTree(); 721 for(TreeEntry group : fEntries) 722 { 723 for(CompilerUIOption uiOpt : group.children) 724 { 725 uiOpt.applyTo(config); 726 } 727 } 601 728 } 602 729 603 730 public void setDefaults(ILaunchConfigurationWorkingCopy config) 604 731 { 605 // TODO Auto-generated method stub 732 initializeTree(); 733 for(TreeEntry group : fEntries) 734 { 735 for(CompilerUIOption uiOpt : group.children) 736 { 737 CompilerOption opt = uiOpt.getOption(); 738 config.setAttribute(opt.getAttributeId(), opt.getDefaultValue()); 739 } 740 } 606 741 } 607 742 608 743 public String validate() 609 744 { 610 // TODO Auto-generated method stub745 // PERHAPS should we allow options to validate themselves? 611 746 return null; 612 747 } … … 654 789 { 655 790 GridLayout layout = new GridLayout(); 656 layout.numColumns = 1;791 layout.numColumns = 2; 657 792 return layout; 658 793 }
