Page tree

MagicDraw 19.0 LTR SP3 Documentation

Every project has project related options. These options are stored together with the project data. Options are organized using and classes. 

Project options belong to three categories:

  1. Visible in the Project Options UI window
  2. Invisible in the Project Options UI window
  3. Personal invisible in the Project Options UI window

Personal options are specific to every user in a server project. It means, every user may have different values of the same option if it is marked as "personal". The personal option is treated as a regular option in a local project.

Retrieving Project Options

Use com.nomagic.magicdraw.core.Project.getOptions().

Retrieving Project Option value

The following example shows how to access project option’s value:

    //retrieving a visible in UI option
    Property property = project.getOptions().getProperty(ProjectOptions.PROJECT_GENERAL_PROPERTIES, "TEST_PROPERTY_ID");
    //retrieving an invisible in UI option
    Property property = project.getOptions().getProperty(ProjectOptions.PROJECT_INVISIBLE_PROPERTIES, "TEST_PROPERTY_ID");
    //retrieving a personal invisible in UI option
    Property property = project.getOptions().getProperty(ProjectOptions.PERSONAL_INVISIBLE_PROPERTIES, "TEST_PROPERTY_ID");
    //retrieving an option value
    if (property != null)
        Object value = property.getValue();

Adding custom project options

Configurators are used for defining a new project options. 

The following example shows, how to add the project option’s configurator at the plugin’s init() method in order to have the additional project option ”Test Property” for every project.

    ProjectOptions.addConfigurator(new ProjectOptionsConfigurator()
        public void configure(ProjectOptions projectOptions)
   property = projectOptions.getProperty(ProjectOptions.PROJECT_GENERAL_PROPERTIES, "TEST_PROPERTY_ID");
            if (property == null)
                // Create a property, if it does not exist
                property = new StringProperty("TEST_PROPERTY_ID", "description");
                // Group
                // The custom resource provider
                property.setResourceProvider(new PropertyResourceProvider()
                    public String getString(String string, Property property)
                        if ("TEST_PROPERTY_ID".equals(string))
                            // Translate ID
                            return "Test Property";
                         if ("TEST_PROPERTY_ID_DESCRIPTION".equals(string))
                            // Translate a description
                            return "Test Property in My Group";
                        if ("MY_GROUP".equals(string))
                            // Translate a group
                            return "My Group";
						return string; 
                // Add a property
                projectOptions.addProperty(ProjectOptions.PROJECT_GENERAL_PROPERTIES, property);
Related pages
  • No labels