1 | package org.rtems.cdt.toolchain;
|
---|
2 |
|
---|
3 | import java.util.Iterator;
|
---|
4 | import java.util.List;
|
---|
5 | import java.util.ArrayList;
|
---|
6 |
|
---|
7 | import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
---|
8 | import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
|
---|
9 | import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
|
---|
10 | import org.eclipse.cdt.managedbuilder.core.IOption;
|
---|
11 | import org.eclipse.cdt.managedbuilder.core.ManagedOptionValueHandler;
|
---|
12 |
|
---|
13 | public class RtemsBspDefinedSymbolsValueHandler extends ManagedOptionValueHandler
|
---|
14 | implements IManagedOptionValueHandler {
|
---|
15 | private List<String> bspDefinedSymbolList;
|
---|
16 |
|
---|
17 | public RtemsBspDefinedSymbolsValueHandler() {
|
---|
18 | bspDefinedSymbolList = RtemsScannerInfoCollector.getBspDefinedSymbols();
|
---|
19 | }
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Handles transfer between values between UI element and
|
---|
23 | * back-end in different circumstances.
|
---|
24 | *
|
---|
25 | * @param configuration build configuration of option
|
---|
26 | * (may be IConfiguration or IResourceConfiguration)
|
---|
27 | * @param holder contains the holder of the option
|
---|
28 | * @param option the option that is handled
|
---|
29 | * @param extraArgument extra argument for handler
|
---|
30 | * @param event event to be handled, one of the following:
|
---|
31 | * (EVENT_OPEN = 1, EVENT_CLOSE = 2,
|
---|
32 | * EVENT_SETDEFAULT = 3,
|
---|
33 | * EVENT_APPLY = 4, EVENT_LOAD = 5)
|
---|
34 | *
|
---|
35 | * @return True when the event was handled, false otherwise.
|
---|
36 | * This enables default event handling can take place.
|
---|
37 | */
|
---|
38 | public boolean handleValue(IBuildObject configuration, IHoldsOptions holder,
|
---|
39 | IOption option, String extraArgument, int event) {
|
---|
40 | if (event == EVENT_CLOSE) return false;
|
---|
41 |
|
---|
42 | try {
|
---|
43 | Object defaultValue = option.getDefaultValue();
|
---|
44 |
|
---|
45 | if ( defaultValue==null
|
---|
46 | || ( defaultValue instanceof List
|
---|
47 | && ((List)defaultValue).size()<=0
|
---|
48 | )
|
---|
49 | ) {
|
---|
50 | option.setDefaultValue(bspDefinedSymbolList);
|
---|
51 | }
|
---|
52 | } catch (Exception e) {
|
---|
53 | return false;
|
---|
54 | }
|
---|
55 |
|
---|
56 | return true;
|
---|
57 | }
|
---|
58 | }
|
---|