0

I am developing an a plugin that definitions build definitions. I have an option where you can add files. That option should be project specific and so data shouldn't persist between projects. I am using a fieldEditor to get the input values.

The problem I am having is that it persists the option values between different projects.

This is what I have in plugin.xml for the option

<option
      browseType="file"
      category="test.category.applications"
      fieldEditor="com.test.FieldEditor"
      command="${value}"
      id="test.applicationFiles"
      name="%option.app.files.name"
      valueType="string">
</option>
halfer
  • 19,824
  • 17
  • 99
  • 186
Varun
  • 31
  • 1
  • 8

1 Answers1

0

As you're yusing field editors I guess you are also using IPreferenceStore to save the user preferences.

If so, then you have to change the scope content. You're probably using INSTANCE scope now:

IScopeContext context = InstanceScope.INSTANCE;

and you should be using project-wide preference scope instead:

IProject handle = ...
IScopeContext context = new ProjectScope(handle);
dreo
  • 910
  • 1
  • 9
  • 20
  • After getting the context, how do i set it for current instance? – Varun Mar 25 '13 at 15:29
  • Sorry, not sure what you're asking for. You don't want it to set to INSTANCE as INSTANCE serves as platform-wide scope. What you need is project-wide scope, represented by aforementioned ProjectScope. After getting the context, just create a preference store and use it as usual: `ScopedPreferenceStore scopedPreferenceStore = new ScopedPreferenceStore(projectScope, Activator.getDefault() .getBundle().getSymbolicName());` – dreo Mar 25 '13 at 15:40
  • I am trying to add an option that uses FieldEditor. The issue is that if I add a parameter for one project, I can see it in the settings of other project. In the init function : public boolean init(IOption option, String extraArgument, String preferenceName, final Composite parent) { init(preferenceName, option.getName()); this.currOption = option; createControl(parent); return true; } The curroption has the text which contains setting from other project. – Varun Mar 25 '13 at 16:25
  • After you edited the question: could you elaborate a bit on what exactly are you trying to achieve and why are you using a CDT extension? So you want to define some C/C++ toolchain? – dreo Mar 25 '13 at 16:56
  • I am trying to make a toolchain which has various tools that provides settings for building. The particular tool I asked you about, makes an executable (.nv). This executable requires some input files as parameters and this option I asked you about is used to add those files. – Varun Mar 25 '13 at 17:13