Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [pde-dev] Storing preferences

Oh, and the file resides here:

${workspace_loc}/.metadata/.plugins/${plugin.name}/mySettings.xml

On Mon, Jul 21, 2008 at 9:02 AM, Aleksandr Kravets <aleksandr.kravets@xxxxxxxxx> wrote:
Hi Erling,

I think IMemento would useful in what you are doing. You basically create a file that will store settings of your plugin:

File savedFile = Activator.getDefault().getStateLocation().append("mySettings.xml").toFile();

Then You populate this file with the data that make sense for you:

XMLMemento root = XMLMemento.createWriteRoot("Root");
IMemento child = root.createChild("Child");
child.putString("childName","myChild");
Writer writer = new FileWriter(savedFile);
xmlMemento.save(writer);

And to read:

FileReader reader = new FileReader(savedFile);
if (reader.ready()) {
    IMemento memento = XMLMemento.createReadRoot(reader);
    IMemento[] children = memento.getChildren(BUG_TYPE);
}


Check API for details, I might have missed something here.

Hope this helps,
Alex


On Mon, Jul 21, 2008 at 8:01 AM, Erling Wegger Linde <erlingwl@xxxxxxxxx> wrote:
Hi,

I'm wondering how I could store the preferences for my plugin.

I don't think I can use the org.eclipse.core.runtime.Preferences;
because I want to store several objects/datasets such as:

server {
- url
- username
- password
- type
}

I'm wondering if I then need to create my own XML file or if there are
any other clever ways to do this?

How (where?) do I store and retrieve this XML file in a way such that
it will work on any Eclipse installation?

If anyone has any tutorials about this, please let me know.

Thanks,
- Erling
_______________________________________________
pde-dev mailing list
pde-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/pde-dev



Back to the top