[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] Saving configuration specific options in own PropertyTab
|
Here is my basic implementation of performApply() and updateData(), an index of a combo box get saved in this example..
With this its possible to save preferences depending on selected build configuration (also proper behaviour when switching to other tab and ok/apply button handling).
protected void updateData(ICResourceDescription cfg)
{
ICConfigurationDescription cfg2 = cfg.getConfiguration();
ICStorageElement el;
try
{
el = cfg2.getStorage(F16_BUILD_PREF_ID,false);
if(el == null)
{
_cpuTypeCombo.select(DEFAULT_CPUIndex);
}
else
{
ICStorageElement[] storageChild = el.getChildrenByName("cpuTypeIndex");
_cpuTypeCombo.select(new Integer(storageChild[0].getAttribute("index")));
}
}
catch (CoreException e)
{
e.printStackTrace();
}
}
protected void performApply(ICResourceDescription src,
ICResourceDescription dst)
{
Integer index = _cpuTypeCombo.getSelectionIndex();
ICConfigurationDescription cfg = dst.getConfiguration();
ICConfigurationDescription srcCfg = src.getConfiguration();
ICStorageElement el;
ICStorageElement el2;
try
{
el = cfg.getStorage(F16_BUILD_PREF_ID,false);
el2 = srcCfg.getStorage(F16_BUILD_PREF_ID,false);
if(el == null)
{
el2 = cfg.getStorage(F16_BUILD_PREF_ID,true);
el2 = el2.createChild("cpuTypeIndex");
el2.setAttribute("index",index.toString());
el = cfg.getStorage(F16_BUILD_PREF_ID,true);
el = el.createChild("cpuTypeIndex");
el.setAttribute("index",index.toString());
_comboIndex = index;
}
else
{
ICStorageElement[] storageChild = el.getChildrenByName("cpuTypeIndex");
storageChild[0].setAttribute("index",index.toString());
ICStorageElement[] storageChild2 = el2.getChildrenByName("cpuTypeIndex");
storageChild2[0].setAttribute("index",index.toString());
_comboIndex = index;
}
}
catch (CoreException e)
{
e.printStackTrace();
}
}
Strange thing is to save the data twice in ICResourceDescription src and dst, if not chaning between tabs has incorrect behaviour.
Second not perfect thing is that performOK() has no possibility to save the configuration because of missing ICResourceDescription parameter, so you have to hold your own ICResourceDescription in your class and do the same like in performApply() there....
But its working, thanks guys :)
>Thanks Wieant,
>with that classes its possible to do configuration dependent settings.
>I just have to find out a proper of the handling in my tab, but basicly it
>should be no problem.
>
>Patrick
>
>
>>> I am extending the build properties by adding a new seperate tabpage.
>>> This tabpage class is extending AbstractCBuildPropertyTab.
>>> First of all I added a combo box with 2 entries.
>>> Now i want that user can save the current entry by hitting the Apply button
>
>>for his current project configuration (also restoring default values and the
>
>>usual settings behaviour).
>>> Is there any code snippet or something how to do it? I take a look in the
>
>>cdt sources, but its not very clear to me how to handle this properly.
>>>
>>> Maybe anybody has a hint for me,
>>
>>We also have our own tab pages extending AbstractCBuildPropertyTab,
>>which we use to set 'standard' CDT options. But to set your own
>>values you should be able to use an ICStorageElement, hope the
>>following snippet is helpful:
>>
>>protected void performApply(ICResourceDescription src,ICResourceDescription
>>dst)
>>{
>> ICConfigurationDescription cfg = dst.getConfiguration();
>> ICStorageElement el = cfg.getStorage("<my.id>",true);
>> el = el.createChild("comboBox");
>> el.setAttribute("value",comboBox.getValue());
>> ...
>>}
>>
>>-- Wieant
>>_______________________________________________
>>cdt-dev mailing list
>>cdt-dev@xxxxxxxxxxx
>>https://dev.eclipse.org/mailman/listinfo/cdt-dev
>
>
>
>--
>Mit freundlichem Gruß
>Patrick Schmitt
>
>-------------------------
>-------------------------
>patrick.schmitt@xxxxxxx
>_______________________________________________
>cdt-dev mailing list
>cdt-dev@xxxxxxxxxxx
>https://dev.eclipse.org/mailman/listinfo/cdt-dev
--
Mit freundlichem Gruß
Patrick Schmitt
-------------------------
-------------------------
patrick.schmitt@xxxxxxx