How to stor config info for plugin

Hi,
I’m creating a plugin that will extract some information from the diagrams and export them to the repository. What i need is to store information about connection string, reporistory name, user and password so i don’t have to type it every time. It may vary between different projects.

And wht i need is your advice. Is there any sugested way to do such things. It would be most convenient if the connection string and repository name is stored within the project while username and password. Username and password i can stor in some xml file in the plugin directory. But i don’t know if there are some practices you can sugest for the other part.

Thanx

Thomas

1 Like

Hello Thomas,

I’m sorry that we do not support saving external information within the project, even using Open API. I suggest you create a custom file (i.e. next to the project file) to save/store those settings. Feel free to contact me for further queries.

Best regards,
Rain

Hello Rain,

Since the question was made quite some time ago, I’d to know if this is still the case.

Best regards,
Claudenir

Hi,
You may store your information (data) in any Model Element,
(e.g. create a Note to store your text in its description.)

In VP, there is a kind of ModelElement, which is used to store user customized data, which is called GenericModel.
You can specify its

  • genericModelType to categorize it
  • tagged value(s) to store your data

On the above case, storing Connection String & Repository Name, code sample:

// SAVE
IGenericModel lLoginInfo = IModelElementFactory.createGenericModel();
lLoginInfo.setGenericModelType("LoginInformation"); // I categorize this GenericModel is a "Login Information"

ITaggedValueContainer lTaggedValues = IModelElementFactory.createTaggedValueContainer();
lLoginInfo.setTaggedValues(lTaggedValues);

ITaggedValue lConnectionString = lTaggedValues.createTaggedValue(); // create a tagged value to store Connection String
lConnectionString.setName("Connection String");
lConnectionString.setValue(...);

ITaggedValue lRepositoryName = lTaggedValues.createTaggedValue(); // create another tagged value to store RepositoryName
lRepositoryName.setName("Repository Name");
lRepositoryName.setValue(...);
// LOAD
IProject lProject = ...;
IModelElement[] lElements = lProject.toModelElementArray(IModelElementFactory.MODEL_TYPE_GENERIC_MODEL);
for (IModelElement lElement : lElements) {
    // find out the LoginInformation from project.
    if ("LoginInformation".equals(((IGenericModel) lElement).getGenericModelType())) {
        IGenericModel lLoginInformation = (IGenericModel) lElement;
        String lConnectionString = lLoginInformation.getTaggedValues().getTaggedValueByName("Connection String").getValue();
        String lRepositoryName = lLoginInformation.getTaggedValues().getTaggedValueByName("Repository Name").getValue();

    }
}