Changeset 1183

Show
Ignore:
Timestamp:
05/29/08 04:27:12 (7 months ago)
Author:
fraserofthenight
Message:

Few minor builder UI changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/descent.building/src/descent/building/IDescentBuilderConstants.java

    r1180 r1183  
    8282    public static final String ATTR_OUTPUT_FILE = "descent.building.debuild.output_file"; 
    8383     
    84     // TODO comment 
     84    /** 
     85     * Add unit tests to the generated executable? 
     86     *  
     87     * Type: String of "true" or "false" 
     88     */ 
    8589    public static final String ATTR_ADD_UNITTESTS = "descent.building.debuild.add_unittests"; 
     90     
     91    /** 
     92     * Disable asserts and contracts (in DMD this is called "release mode"). In 
     93     * other compilers, if asserions, contracts, and array bounds errors can be 
     94     * disabled separately, this option should only be for disabling asserts, 
     95     * however clients should be aware that other features may be disabled as well 
     96     * in generated code. 
     97     *  
     98     * If the compiler does not support disabling of assertions, this option 
     99     * should be ignored. If the compiler does not support assertions at all, but 
     100     * this attribute was specified outside the UI to be explicitly "false", an error 
     101     * should be marked. 
     102     *  
     103     * Type: String of "true" or "false" 
     104     */ 
    86105    public static final String ATTR_DISABLE_ASSERTS = "descent.building.debuild.disable_asserts"; 
     106     
     107    /** 
     108     * Include debugging symbols in the generated executable.  
     109     *  
     110     * If the compiler supports multiple kinds of debugging symbols, the system 
     111     * default should be used. If a default cannot be determined or the compiler 
     112     * does not support adding of debugging symbols, an error should be marked. 
     113     *  
     114     * Type: String of "true" or "false" 
     115     */ 
    87116    public static final String ATTR_ADD_DEBUG_INFO = "descent.building.debuild.add_debug_info"; 
     117     
     118    /** 
     119     * Include code allowing code coverage to be tracked in the generated 
     120     * executable. 
     121     *  
     122     * If the compiler does not support debug symbols, an error should be marked. 
     123     *  
     124     * Type: String of "true" or "false" 
     125     */ 
    88126    public static final String ATTR_INSTRUMENT_FOR_COVERAGE = "descent.building.debuild.instrument_for_coverage"; 
     127     
     128    /** 
     129     * Include code for profiling the executable. 
     130     *  
     131     * If the compiler supports multiple kinds of profile information, the system 
     132     * default should be used. If a default cannot be determined or the compiler 
     133     * does not support adding of profile information, an error should be marked. 
     134     *  
     135     * Type: String of "true" or "false" 
     136     */ 
    89137    public static final String ATTR_INSTRUMENT_FOR_PROFILE = "descent.building.debuild.instrument_for_profile"; 
     138     
     139    /** 
     140     * A set of additional compiler arguments that should be added to 
     141     * the command line when calling the compiler. 
     142     *  
     143     * Type: String 
     144     */ 
     145    public static final String ATTR_ADDITIONAL_COMPILER_ARGS = "descent.building.debuild.compiler_args"; 
     146     
     147    /** 
     148     * A set of additional linker arguments that should be added to 
     149     * the command line when calling the linker. 
     150     *  
     151     * Type: String 
     152     */ 
     153    public static final String ATTR_ADDITIONAL_LINKER_ARGS = "descent.building.debuild.linker_args"; 
    90154     
    91155    /** 
  • trunk/descent.building/src/descent/building/compiler/StringOption.java

    r1180 r1183  
    11package descent.building.compiler; 
    22 
    3 public class StringOption extends CompilerOption 
     3public class StringOption extends CompilerOption implements IValidatableOption 
    44{ 
    55    public StringOption(String attributeId, String defaultValue, 
     
    88        super(attributeId, defaultValue, label, groupLabel, helpText); 
    99    } 
     10     
     11    public String isValid(String value) 
     12    { 
     13        return null; 
     14    } 
    1015} 
  • trunk/descent.building/src/descent/internal/building/compiler/DmdCompilerInterface.java

    r1180 r1183  
    268268         
    269269        // TODO file options for header & doc generation 
     270        // TODO Only Windows uses OPTLINK, make a separate list of linker 
     271        // options for Linux 
    270272        uiOptions = new CompilerOption[] 
    271273        {            
     
    273275            // Features 
    274276             
    275             new BooleanOption( 
     277            new BooleanOption 
     278            ( 
    276279                    ATTR_ADD_DEBUG_INFO, 
    277280                    true, 
     
    282285                    "Adds debugging symbols. These make the generated objects " + 
    283286                    "slightly larger but is needed to use a debugger with the " + 
    284                     "program."), 
     287                    "program." 
     288            ), 
    285289                     
    286             new BooleanOption( 
     290            new BooleanOption 
     291            ( 
    287292                    ATTR_DISABLE_ASSERTS, 
    288293                    false, 
    289                     "Release mode (disable asserts & contracts)", 
     294                    "Release mode", 
    290295                    GROUP_FEATURES, 
    291296                    "-release", 
     
    294299                    "blocks on functions, and checking for array bounds errors. This " + 
    295300                    "makes the code run faster, so is a good choice for releasing the " + 
    296                     "application, but are often useful for development."), 
     301                    "application, but are often useful for development." 
     302            ), 
    297303                     
    298                      
    299             new BooleanOption
     304            new BooleanOption 
     305           
    300306                    ATTR_ADD_UNITTESTS, 
    301307                    false, 
     
    305311                    "", 
    306312                    "Adds code so that unittest {} blocks in your code are run before " + 
    307                     "the program launches and enables version(unitttest) {} blocks."), 
     313                    "the program launches and enables version(unitttest) {} blocks." 
     314            ), 
    308315                             
    309             new BooleanOption( 
     316            new BooleanOption 
     317            ( 
    310318                    ATTR_INSTRUMENT_FOR_COVERAGE, 
    311319                    false, 
     
    317325                    "a file containing code coverage information after the program " + 
    318326                    "has been run. This is useful for seeing if unit tests execute " + 
    319                     "all paths in your code."), 
     327                    "all paths in your code." 
     328            ), 
    320329                                     
    321             new BooleanOption( 
     330            new BooleanOption 
     331            ( 
    322332                    ATTR_INSTRUMENT_FOR_PROFILE, 
    323333                    false, 
     
    328338                    "Adds code to the generated objects so they can be prodiled. " + 
    329339                    "This helps find bottlenecks that could be slowing down your " + 
    330                     "application."), 
     340                    "application." 
     341            ), 
    331342             
    332343            //------------------------------------------------------------------ 
    333344            // Warnings 
    334345             
    335             new BooleanOption( 
     346            new BooleanOption 
     347            ( 
    336348                    ATTR_ALLOW_DEPRECATED, 
    337349                    true, 
     
    341353                    "", 
    342354                    "Allows code marked with the \"deprecated\" tags to be included " + 
    343                     "in your program."), 
    344              
    345             new BooleanOption( 
     355                    "in your program." 
     356            ), 
     357             
     358            new BooleanOption 
     359            ( 
    346360                    ATTR_SHOW_WARNINGS, 
    347361                    false, 
     
    352366                    "Adds warnings for potentially unsafe or error-prone code. In " + 
    353367                    "DMD, if warnings are encountered, the program will not be " + 
    354                     "compiled."), 
     368                    "compiled." 
     369            ), 
    355370             
    356371               
     
    358373            // Optimization 
    359374             
    360             new BooleanOption( 
     375            new BooleanOption 
     376            ( 
    361377                    ATTR_OPTIMIZE_CODE, 
    362378                    false, 
     
    365381                    "-O", 
    366382                    "", 
    367                     "Optimizes the generated code for best efficiency."), 
     383                    "Optimizes the generated code for best efficiency." 
     384            ), 
    368385             
    369             new BooleanOption( 
     386            new BooleanOption 
     387            ( 
    370388                    ATTR_INLINE_CODE, 
    371389                    false, 
     
    375393                    "", 
    376394                    "Allows inlining of short functions for increased code efficiency. " + 
    377                     "This may cause issues with some debuggers."), 
    378              
    379             new BooleanOption( 
     395                    "This may cause issues with some debuggers." 
     396             ), 
     397             
     398            new BooleanOption 
     399            ( 
    380400                    ATTR_NOFLOAT, 
    381401                    false, 
     
    386406                    "Prevents the emission of the __fltused reference in object files, " + 
    387407                    "even if floating point code is present. This is useful in library " + 
    388                     "files."), 
     408                    "files." 
     409            ), 
    389410        }; 
    390411    } 
  • trunk/descent.building/src/descent/internal/building/compiler/IDmdCompilerConstants.java

    r1180 r1183  
    44{ 
    55    // TODO comment 
     6     
     7    // Compiler 
    68    public static final String ATTR_ALLOW_DEPRECATED = "descent.building.compiler.dmd.allow_deprectaed"; 
    79    public static final String ATTR_SHOW_WARNINGS = "descent.building.compiler.dmd.show_warnings"; 
     
    911    public static final String ATTR_OPTIMIZE_CODE = "descent.building.compiler.dmd.optimize_code"; 
    1012    public static final String ATTR_NOFLOAT = "descent.building.compiler.dmd.nofloat"; 
     13     
     14    // TODO linker options (both optlink and ld). Many of these options will be 
     15    // passed by the compiler, and about half of OPTLINK's options are ignored or 
     16    // apply to 16-bit code anyways. It may be fine to just have a box for "additional 
     17    // arguments" somewhere and allow the user to put them in as they want. 
    1118} 
  • trunk/descent.building/src/descent/internal/building/ui/AbstractBuilderTab.java

    r1177 r1183  
    33import java.util.ArrayList; 
    44import java.util.List; 
     5import java.util.Map; 
     6import java.util.Set; 
    57 
    68import org.eclipse.core.resources.IWorkspaceRoot; 
     
    193195        private final boolean fEditable; 
    194196         
    195         protected Label fLabel; 
    196197        protected Text fText; 
    197         protected Button fButton; 
    198198         
    199199        /** 
     
    203203         * @param label         the text of the label 
    204204         * @param numColumns    the number of columns the three controls should 
    205          *                      take up. Must be >= 2 if no browse button and 
    206          *                      >= 3 if there is a browse button 
     205         *                      take up. 
    207206         * @param browseButton  should there be a browse button? if this is true, 
    208          *                      numColumns must be >= 3 and {@link #browse()} must 
    209          *                      be implemented in the subclass. 
     207         *                      {@link #browse()} must be implemented in the subclass. 
    210208         * @param editable      sets whether or not the text field is editable. 
    211209         *                      This should only be false if browseButton is true, 
     
    224222        public final void addToControl(Composite comp) 
    225223        { 
    226             fLabel = new Label(comp, SWT.NONE); 
    227             fLabel.setText(fLabelString); 
    228             GridData gd = new GridData(); 
     224            comp = new Composite(comp, SWT.NONE); 
     225            GridData gd = new GridData(GridData.FILL_HORIZONTAL); 
     226            gd.horizontalSpan = fNumColumns; 
     227            comp.setLayoutData(gd); 
     228             
     229            GridLayout layout = new GridLayout(); 
     230            layout.numColumns = fBrowseButton ? 3 : 2; 
     231            comp.setLayout(layout); 
     232             
     233            Label label = new Label(comp, SWT.NONE); 
     234            label.setText(fLabelString); 
     235            gd = new GridData(); 
    229236            gd.horizontalSpan = 1; 
    230             fLabel.setLayoutData(gd); 
     237            label.setLayoutData(gd); 
    231238     
    232239            fText = new Text(comp, SWT.SINGLE | SWT.BORDER); 
    233240            gd = new GridData(GridData.FILL_HORIZONTAL); 
    234             gd.horizontalSpan = fNumColumns - (fBrowseButton ? 2 : 1)
     241            gd.horizontalSpan = 1
    235242            fText.setLayoutData(gd); 
    236243            fText.setEditable(fEditable); 
     
    246253            if(fBrowseButton) 
    247254            { 
    248                 fButton = new Button(comp, SWT.PUSH); 
    249                 fButton.setText("Browse..."); 
     255                Button button = new Button(comp, SWT.PUSH); 
     256                button.setText("Browse..."); 
    250257                gd = new GridData(); 
    251258                gd.horizontalSpan = 1; 
    252                 fButton.setLayoutData(gd); 
    253                 setButtonDimensionHint(fButton); 
    254                 fButton.addSelectionListener(new SelectionAdapter() 
     259                button.setLayoutData(gd); 
     260                setButtonDimensionHint(button); 
     261                button.addSelectionListener(new SelectionAdapter() 
    255262                { 
    256263                    public void widgetSelected(SelectionEvent evt) 
     
    276283 
    277284        public final void initializeFrom(ILaunchConfiguration config) 
    278         { 
    279             String value = ""; 
    280             try 
    281             { 
    282                 value = config.getAttribute(fAttribute, ""); 
    283             } 
    284             catch(CoreException e) { } 
    285              
    286             fText.setText(value); 
     285        {    
     286            fText.setText(getAttribute(config, fAttribute, "")); 
    287287        } 
    288288 
     
    586586        return ResourcesPlugin.getWorkspace().getRoot(); 
    587587    } 
     588     
     589    //-------------------------------------------------------------------------- 
     590    // Wrappers for ILaunchConfiguration methods which hide the exceptions, 
     591    // since the exception will never be thrown 
     592     
     593    protected static String getAttribute(ILaunchConfiguration config, String id, 
     594            String defaultValue) 
     595    { 
     596        String value = defaultValue; 
     597        try 
     598        { 
     599            value = config.getAttribute(id, defaultValue); 
     600        } 
     601        catch(CoreException e) { } 
     602        return value; 
     603    } 
     604     
     605    protected static boolean getAttribute(ILaunchConfiguration config, String id, 
     606            boolean defaultValue) 
     607    { 
     608        boolean value = defaultValue; 
     609        try 
     610        { 
     611            value = config.getAttribute(id, defaultValue); 
     612        } 
     613        catch(CoreException e) { } 
     614        return value; 
     615    } 
     616     
     617    protected static int getAttribute(ILaunchConfiguration config, String id, 
     618            int defaultValue) 
     619    { 
     620        int value = defaultValue; 
     621        try 
     622        { 
     623            value = config.getAttribute(id, defaultValue); 
     624        } 
     625        catch(CoreException e) { } 
     626        return value; 
     627    } 
     628     
     629    @SuppressWarnings("unchecked") 
     630    protected static List getAttribute(ILaunchConfiguration config, String id, 
     631            List defaultValue) 
     632    { 
     633        List value = defaultValue; 
     634        try 
     635        { 
     636            value = config.getAttribute(id, defaultValue); 
     637        } 
     638        catch(CoreException e) { } 
     639        return value; 
     640    } 
     641     
     642    @SuppressWarnings("unchecked") 
     643    protected static Map getAttribute(ILaunchConfiguration config, String id, 
     644            Map defaultValue) 
     645    { 
     646        Map value = defaultValue; 
     647        try 
     648        { 
     649            value = config.getAttribute(id, defaultValue); 
     650        } 
     651        catch(CoreException e) { } 
     652        return value; 
     653    } 
     654     
     655    @SuppressWarnings("unchecked") 
     656    protected static Set getAttribute(ILaunchConfiguration config, String id, 
     657            Set defaultValue) 
     658    { 
     659        Set value = defaultValue; 
     660        try 
     661        { 
     662            value = config.getAttribute(id, defaultValue); 
     663        } 
     664        catch(CoreException e) { } 
     665        return value; 
     666    } 
    588667} 
  • trunk/descent.building/src/descent/internal/building/ui/CompilerTab.java

    r1180 r1183  
    66import java.util.TreeMap; 
    77 
    8 import org.eclipse.core.runtime.CoreException; 
    98import org.eclipse.debug.core.ILaunchConfiguration; 
    109import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 
     
    3130import org.eclipse.swt.events.SelectionAdapter; 
    3231import org.eclipse.swt.events.SelectionEvent; 
     32import org.eclipse.swt.graphics.Font; 
     33import org.eclipse.swt.graphics.FontData; 
    3334import org.eclipse.swt.graphics.Image; 
    3435import org.eclipse.swt.layout.GridData; 
     
    4041import org.eclipse.swt.widgets.Layout; 
    4142import org.eclipse.swt.widgets.Link; 
     43import org.eclipse.swt.widgets.Text; 
    4244import org.eclipse.ui.dialogs.PreferencesUtil; 
    4345 
     
    4749import descent.building.compiler.EnumOption; 
    4850import descent.building.compiler.ICompilerInterface; 
     51import descent.building.compiler.IValidatableOption; 
    4952import descent.building.compiler.StringOption; 
    5053import descent.internal.building.compiler.DmdCompilerInterface; 
     
    7780             
    7881            fHelpText = new Link(comp, SWT.LEFT | SWT.WRAP); 
    79             fHelpText.setText("Select the compiler/standard library set to use " + 
    80                     "for this build configuration. Use the <a>Compilers " + 
    81                     "preference page</a> to set up compiler/standard library " + 
    82                     "configurations."); 
     82            fHelpText.setText("Use the <a>Compilers preference page</a> to set up " + 
     83                    "compiler/standard library configurations"); 
    8384            gd = new GridData(GridData.FILL_BOTH); 
    8485            gd.horizontalSpan = 2; 
     
    102103             
    103104            fCombo = new Combo(comp, SWT.DROP_DOWN | SWT.READ_ONLY); 
    104             gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); 
     105            gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); 
    105106            gd.horizontalSpan = 1; 
    106             gd.grabExcessHorizontalSpace = true; 
    107107            fCombo.addModifyListener(new ModifyListener() 
    108108            { 
     
    167167        public void initializeFrom(ILaunchConfiguration config) 
    168168        { 
    169             String compilerTypeId = ""; 
    170             try 
    171             { 
    172                 compilerTypeId = config.getAttribute(IDescentBuilderConstants.ATTR_COMPILER_TYPE_ID, ""); 
    173             } 
    174             catch(CoreException e) { } 
    175              
    176             String compilerId = ""; 
    177             try 
    178             { 
    179                 compilerId = config.getAttribute(IDescentBuilderConstants.ATTR_COMPILER_ID, ""); 
    180             } 
    181             catch(CoreException e) { } 
     169            String compilerTypeId = getAttribute(config,  
     170                    IDescentBuilderConstants.ATTR_COMPILER_TYPE_ID, ""); 
     171            String compilerId = getAttribute(config,  
     172                    IDescentBuilderConstants.ATTR_COMPILER_ID, ""); 
    182173             
    183174            for(int i = 0; i < fCompilers.length; i++) 
     
    238229    } 
    239230     
    240     public class CompilerOptions implements ISetting 
     231    private final class CompilerOptions implements ISetting 
    241232    { 
    242233        private abstract class CompilerUIOption 
     
    250241            public abstract String getText(); 
    251242            public abstract void initializeTo(String value); 
    252             public abstract void applyTo(ILaunchConfigurationWorkingCopy config); 
     243            public abstract String getStringValue(); 
    253244        } 
    254245         
     
    304295 
    305296            @Override 
    306             public void applyTo(ILaunchConfigurationWorkingCopy config) 
    307             { 
    308                 config.setAttribute(option.getAttributeId(), 
    309                         selected ? "true" : "false"); 
     297            public String getStringValue() 
     298            { 
     299                return selected ? "true" : "false"; 
    310300            } 
    311301        } 
     
    373363             
    374364            @Override 
    375             public void applyTo(ILaunchConfigurationWorkingCopy config) 
    376             { 
    377                 config.setAttribute(getOption().getAttributeId(), 
    378                         option.getOptionValues()[selected.intValue()]); 
     365            public String getStringValue() 
     366            { 
     367                return option.getOptionValues()[selected.intValue()]; 
    379368            } 
    380369        } 
     
    431420             
    432421            @Override 
    433             public void applyTo(ILaunchConfigurationWorkingCopy config
    434             { 
    435                 config.setAttribute(getOption().getAttributeId(), selected)
     422            public String getStringValue(
     423            { 
     424                return selected
    436425            } 
    437426        } 
     
    497486        private TreeEntry[] fEntries; 
    498487        private Group fHelpGroup; 
     488        private Label fHelpHeader; 
    499489        private Label fHelpText; 
    500490         
     
    528518             
    529519            column = new TreeViewerColumn(fViewer, SWT.NONE); 
    530             column.getColumn().setWidth(200); 
     520            column.getColumn().setWidth(175); 
    531521            column.getColumn().setText("Value"); 
    532522            column.setLabelProvider(new ColumnLabelProvider() 
     
    593583            gd = new GridData(GridData.FILL_VERTICAL); 
    594584            gd.horizontalSpan = 1; 
    595             gd.widthHint = 200; // PERHAPS use PixelConverter or something...? 
     585            gd.widthHint = 225; // PERHAPS use PixelConverter or something...? 
    596586            fHelpGroup.setLayoutData(gd); 
    597587             
     
    599589            groupLayout.numColumns = 1; 
    600590            fHelpGroup.setLayout(groupLayout); 
     591             
     592            fHelpHeader = new Label(fHelpGroup, SWT.LEFT); 
     593            gd = new GridData(GridData.FILL_HORIZONTAL); 
     594            gd.horizontalSpan = 1; 
     595            fHelpHeader.setText(""); 
     596            fHelpHeader.setFont(getBoldFont(comp)); 
     597            fHelpHeader.setLayoutData(gd); 
    601598             
    602599            fHelpText = new Label(fHelpGroup, SWT.LEFT | SWT.WRAP); 
     
    613610                    if(0 == paths.length) 
    614611                    { 
    615                         fHelpText.setText(""); 
    616                         fHelpText.update(); 
     612                        unsetHelp(); 
    617613                        return; 
    618614                    } 
     
    621617                    if(!(selected instanceof CompilerUIOption)) 
    622618                    { 
    623                         fHelpText.setText(""); 
    624                         fHelpText.update(); 
     619                        unsetHelp(); 
    625620                        return; 
    626621                    } 
    627622                     
     623                     
     624                    fHelpHeader.setText(((CompilerUIOption) selected).getOption(). 
     625                            getLabel()); 
    628626                    fHelpText.setText(((CompilerUIOption) selected).getOption(). 
    629627                            getHelpText()); 
     628                    updateHelp(); 
     629                } 
     630                 
     631                private void unsetHelp() 
     632                { 
     633                    fHelpHeader.setText(""); 
     634                    fHelpText.setText(""); 
     635                    updateHelp(); 
     636                } 
     637                 
     638                private void updateHelp() 
     639                { 
     640                    fHelpHeader.update(); 
    630641                    fHelpText.update(); 
    631642                } 
     
    704715                    CompilerOption opt = uiOpt.getOption(); 
    705716                    String defaultValue = opt.getDefaultValue(); 
    706                     String value = defaultValue; 
    707                     try 
    708                     { 
    709                         value = config.getAttribute(opt.getAttributeId(), defaultValue); 
    710                     } 
    711                     catch(CoreException e) { } 
     717                    String value = getAttribute(config, opt.getAttributeId(), defaultValue); 
    712718                    uiOpt.initializeTo(value); 
    713719                    fViewer.update(uiOpt, null); 
     
    723729                for(CompilerUIOption uiOpt : group.children) 
    724730                { 
    725                     uiOpt.applyTo(config); 
     731                    CompilerOption opt = uiOpt.getOption(); 
     732                    config.setAttribute(opt.getAttributeId(), uiOpt.getStringValue()); 
    726733                } 
    727734            } 
     
    743750        public String validate() 
    744751        { 
    745             // PERHAPS should we allow options to validate themselves? 
     752            for(TreeEntry group : fEntries) 
     753            { 
     754                for(CompilerUIOption uiOpt : group.children) 
     755                { 
     756                    CompilerOption opt = uiOpt.getOption(); 
     757                    if(opt instanceof IValidatableOption) 
     758                    { 
     759                        String msg = ((IValidatableOption) opt).isValid(uiOpt.getStringValue()); 
     760                        if(null != msg) 
     761                            return msg; 
     762                    } 
     763                } 
     764            } 
    746765            return null; 
    747766        } 
     
    749768     
    750769    //-------------------------------------------------------------------------- 
    751     // Icon management 
     770    // Additional arguments 
     771     
     772    private final class ArgumentsSetting implements ISetting 
     773    { 
     774        private Text fCompilerText; 
     775        private Text fLinkerText; 
     776         
     777        public final void addToControl(Composite comp) 
     778        {    
     779            comp = new Composite(comp, SWT.NONE); 
     780            GridData gd = new GridData(GridData.FILL_HORIZONTAL); 
     781            gd.horizontalSpan = 2; 
     782            comp.setLayoutData(gd); 
     783             
     784            GridLayout layout = new GridLayout(); 
     785            layout.numColumns = 2; 
     786            comp.setLayout(layout); 
     787             
     788            addLabel(comp, "Additional compiler args:"); 
     789            fCompilerText = addText(comp); 
     790             
     791            addLabel(comp, "Additional linker args:"); 
     792            fLinkerText = addText(comp); 
     793        } 
     794         
     795        private Label addLabel(Composite comp, String str) 
     796        { 
     797            Label label = new Label(comp, SWT.NONE); 
     798            label.setText(str); 
     799            GridData gd = new GridData(); 
     800            gd.horizontalSpan = 1; 
     801            label.setLayoutData(gd); 
     802            return label; 
     803        } 
     804         
     805        private Text addText(Composite comp) 
     806        { 
     807            Text text = new Text(comp, SWT.SINGLE | SWT.BORDER); 
     808            GridData gd = new GridData(GridData.FILL_HORIZONTAL); 
     809            gd.horizontalSpan = 1; 
     810            text.setLayoutData(gd); 
     811            text.addModifyListener(new ModifyListener() 
     812            { 
     813                public void modifyText(ModifyEvent evt) 
     814                { 
     815                    validatePage(); 
     816                    updateLaunchConfigurationDialog(); 
     817                } 
     818            }); 
     819            return text; 
     820        } 
     821         
     822        public void setDefaults(ILaunchConfigurationWorkingCopy config) 
     823        { 
     824            config.setAttribute(IDescentBuilderConstants.ATTR_ADDITIONAL_COMPILER_ARGS, ""); 
     825            config.setAttribute(IDescentBuilderConstants.ATTR_ADDITIONAL_LINKER_ARGS, ""); 
     826        } 
     827         
     828        public void initializeFrom(ILaunchConfiguration config) 
     829        { 
     830            fCompilerText.setText(getAttribute(config, IDescentBuilderConstants.ATTR_ADDITIONAL_COMPILER_ARGS, "")); 
     831            fLinkerText.setText(getAttribute(config, IDescentBuilderConstants.ATTR_ADDITIONAL_LINKER_ARGS, "")); 
     832        } 
     833 
     834        public void performApply(ILaunchConfigurationWorkingCopy config) 
     835        { 
     836            config.setAttribute(IDescentBuilderConstants.ATTR_ADDITIONAL_COMPILER_ARGS, fCompilerText.getText()); 
     837            config.setAttribute(IDescentBuilderConstants.ATTR_ADDITIONAL_LINKER_ARGS, fLinkerText.getText()); 
     838        } 
     839         
     840        public String validate() 
     841        { 
     842            // Assume anything is valid... this setting is for advanced users who 
     843            // should know what they're doing 
     844            return null; 
     845        } 
     846    } 
     847     
     848    //-------------------------------------------------------------------------- 
     849    // Resource management 
    752850     
    753851    // This needs to be done at the tab level to allow for disposing) 
     
    755853    private Image fCheckedIcon = createImage("obj16/checked.png"); 
    756854    private Image fUncheckedIcon = createImage("obj16/unchecked.png"); 
     855    private Font fBoldFont; 
     856     
     857    private Font getBoldFont(Composite comp) 
     858    { 
     859        if(null == fBoldFont) 
     860        { 
     861            FontData[] fontData = comp.getFont().getFontData(); 
     862            for(FontData dataItem : fontData) 
     863                dataItem.setStyle(dataItem.getStyle() | SWT.BOLD); 
     864            fBoldFont = new Font(comp.getDisplay(), fontData); 
     865        } 
     866        return fBoldFont; 
     867    } 
    757868     
    758869    public void dispose() 
     
    761872        fCheckedIcon.dispose(); 
    762873        fUncheckedIcon.dispose(); 
     874        if(null != fBoldFont) 
     875            fBoldFont.dispose(); 
    763876    } 
    764877     
     
    782895            new CompilerSetting(), 
    783896            compilerOptions, 
     897            new ArgumentsSetting(), 
    784898        }; 
    785899    } 
  • trunk/descent.building/src/descent/internal/building/ui/GeneralTab.java

    r1177 r1183  
    11package descent.internal.building.ui; 
    22 
     3import java.util.ArrayList; 
    34import java.util.List; 
    45 
     
    67import org.eclipse.core.resources.IResource; 
    78import org.eclipse.core.resources.ResourcesPlugin; 
    8 import org.eclipse.core.runtime.CoreException; 
    99import org.eclipse.core.runtime.IPath; 
    1010import org.eclipse.core.runtime.IStatus; 
     
    1313import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 
    1414import org.eclipse.jface.viewers.ILabelProvider; 
     15import org.eclipse.jface.viewers.LabelProvider; 
    1516import org.eclipse.jface.window.Window; 
    1617import org.eclipse.swt.SWT; 
    1718import org.eclipse.swt.events.SelectionAdapter; 
    1819import org.eclipse.swt.events.SelectionEvent; 
     20import org.eclipse.swt.graphics.Image; 
    1921import org.eclipse.swt.layout.GridData; 
    2022import org.eclipse.swt.layout.GridLayout; 
     
    2729import org.eclipse.ui.dialogs.ElementListSelectionDialog; 
    2830 
     31import descent.core.IJavaElement; 
    2932import descent.core.IJavaProject; 
    3033import descent.core.JavaCore; 
     
    174177    private final class OutputTypeSetting implements ISetting 
    175178    { 
    176         private Label fLabel; 
    177179        private Button fExecutableRadio; 
    178180        private Button fStaticLibRadio; 
     
    183185        public void addToControl(Composite comp) 
    184186        {    
    185             fLabel = new Label(comp, SWT.LEFT); 
    186             fLabel.setText("Target type:"); 
     187            Label label = new Label(comp, SWT.LEFT); 
     188            label.setText("Target type:"); 
    187189            GridData gd = new GridData(); 
    188190            gd.horizontalSpan = 3; 
    189             fLabel.setLayoutData(gd); 
     191            label.setLayoutData(gd); 
    190192             
    191193            fExecutableRadio = createRadioButton(comp, 3, "Executable", 25,  
     
    221223                        } 
    222224                    }); 
    223             createSpacer(comp, 3); 
    224225        } 
    225226 
    226227        public void initializeFrom(ILaunchConfiguration config) 
    227228        { 
    228             String outputType = OUTPUT_TYPE_EXECUTABLE; 
    229             try 
    230             { 
    231                 outputType = config.getAttribute(ATTR_OUTPUT_TYPE, OUTPUT_TYPE_EXECUTABLE); 
    232             } 
    233             catch(CoreException e) { } 
     229            String outputType = getAttribute(config, ATTR_OUTPUT_TYPE, 
     230                    OUTPUT_TYPE_EXECUTABLE); 
    234231             
    235232            if(outputType.equals(OUTPUT_TYPE_STATIC_LIBRARY)) 
     
    431428    private final class ModulesSetting implements ISetting 
    432429    { 
    433         private Group fGroup;