Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "CDT/Developer/Code Snippets"

< CDT
(Programmatically set an option in the project settings)
(Programmatically set an option in the project settings)
Line 31: Line 31:
 
== Build Related Snippets ==
 
== Build Related Snippets ==
  
===  Programmatically set an option in the project settings ===
+
===  Programmatically set an option in the project settings UNDER CONSTRUCTION ===
 
Before we get into the code, you have to understand a couple of concepts:   
 
Before we get into the code, you have to understand a couple of concepts:   
  

Revision as of 14:46, 26 June 2014


General

During CDT development, you may be interested in using code snippets to get certain things done. This page categorizes and provides these code snippets and explains their usage context.

Please feel free to fix bugs in code below or suggest improvements on talk page.

Template Category

Copy & paste, explain what the category is about.

Template snippet

Explanation

source code:

  System.out.println("Hello world");

UI Snippets

Snippets related to making dialogues or explaining how to interact with it.

Launch a dialogue from a non-ui thread and get a return value

Please see [Launch a dialogue from a non-ui thread and get a return value]

Dialogue for caught exceptions

Often when catching exceptions, it's puzzling as to what one is suppose to do with them.

Please see [Message Dialogue for exceptions]

Build Related Snippets

Programmatically set an option in the project settings UNDER CONSTRUCTION

Before we get into the code, you have to understand a couple of concepts:

C and C++ build settings are stored in the .cproject file in the root folder of your project. It's an xml file with your settings.

  • ITool -- an ITool is a sort of utility. Here are a few examples of tools:

GCC Archiver, GCC C++ Compiler, GCC C Compiler, GCC C Linker, GCC C++ Linker, GCC Assembler

  • ITool extends IHoldsOptions -- i.e, methods that ask for an IHoldsOptions will happily accept an ITool.
  • IOption -- an IOption holds some configuration. E.g a boolean whether a checkbox is checked/unchecked.

Now one must note, there are instances of an IOption that are generic 'abstract' instances of an option, and there are more concrete IOptions that can be used to save to disk.

One must also be careful as to how one aquires the IHoldsOptions. You should avoid getting IHoldsOption from the option directly, because if setting it for the first time, it might not be defined and your save-to-disk won't work. Instead get the IHoldsOption directly from your configuration and then get a mutable copy of IOptions from this IHolds options.

The code below assumes you have access to your IProject instance. If not please see: getting IProject

     UNDER CONSTRUCTION.

Back to the top