Home
Categories
Dictionary
Download
Project Details
Changes Log
Tutorials
FAQ
License

Application description



It is possible to specify the Application description which can contain:
  • The Application name
  • The Application version
  • The Application build date
  • An alternate text which can replace these informations if they are not present
The ApplicationDesc is the class which hold these informations.

Getting a default description

It is possible to get a default description with:

This description has default values:
  • The Application or Plugin name is the name of the application class or Plugin class
  • The Application or Plugin version is null
  • The Application or Plugin build date is null
  • The alternate text is null

Contrary to the Plugin.getPluginDesc() method, the Plugin.getPluginDescription() method will return the description altennate text if the Plugin

Customizing the description

After having obtained the default description with the AbstractApplication.getApplicationDesc() method , you can customize these values as you need, for example:
      public class AboutTutorialMDI extends AbstractMDIApplication {
         public AboutTutorialMDI() {
           super("MDISimpleExample");
           ApplicationDesc desc = getApplicationDesc();
           desc.setApplicationName("MyApplication");
           desc.setVersion("0.1");
           desc.setBuildDate("2023/10/05");
         }
      }

Having only an alternate text

If you want to have only the alternate text, you must clear the Application name, for example:
      public class AboutTutorialMDI extends AbstractMDIApplication {
         public AboutTutorialMDI() {
           super("MDISimpleExample");
           ApplicationDesc desc = getApplicationDesc();
           desc.setApplicationName(null);
           desc.setAlternateText("My customized description");
         }
      }

Note that you can keep the Application name, date, and version, and the alternate text. For example:
         public class AboutTutorialMDI extends AbstractMDIApplication {
            public AboutTutorialMDI() {
              super("MDISimpleExample");
              ApplicationDesc desc = getApplicationDesc();
              desc.setApplicationName("MyApplication");
              desc.setVersion("0.1");
              desc.setBuildDate("2023/10/05");
              desc.setAlternateText("My customized description");
            }
         }


Getting the description from the configuration

Basic method

It is possible to set the content of the Application description from the configuration by implementing the Configuration.setupApplicationDesc(ApplicationDesc) method. This can be useful if you store the application name, version, build date, or alternate text from the configuration. For example:
      public class MyConfiguration implements Configuration {
         private static MyConfiguration conf = null;
         public String version = null;
         public String date = null;

         public static MyConfiguration getInstance() {
           if (conf == null) {
             conf = new MyConfiguration();
           }
           return conf;
         }
      _
         public MyConfiguration() {
            InputStream stream = this.getClass().getResourceAsStream("properties.properties");
            PropertyResourceBundle bundle = new PropertyResourceBundle(stream);
            version = bundle.getString("version");
            date = bundle.getString("date");
            stream.close();
         }
      _
         public void setupApplicationDesc(ApplicationDesc appDesc) {
           appDesc.setVersion(version);
           appDesc.setBuildDate(date);
         }
      }

Using the framework

The MDIConfigUtils class allows to get the content of an ApplicationDesc directly from a properties file: The fields will be set with the following properties names:
  • "name": The Application or Plugin name
  • "desc": The Application or Plugin description
  • "version": The Application or Plugin version
  • "date": The Application or Plugin date

Note that none of those fields are mandatory. For example, normally you won't need to set the name of the Plugin, because if will be directly get from the Plugin Manifest.

Example

For the application, we may have this code in the main application class:
      public class MyApplication extends AbstractMDIApplication {
         private Preferences pref = null;

         public MyApplication() {
           super("My Application");
           conf = AppliConfiguration.getInstance();
              conf.setupApplicationDesc(getApplicationDesc());
           ...
      }
For the configuration:
      public class AppliConfiguration implements Configuration {
         private static AppliConfiguration conf = null;

         private AppliConfiguration() {
         }

         public static AppliConfiguration getInstance() {
           if (conf == null) {
             conf = new AppliConfiguration();
           }
           return conf;
         }

         @Override
         public void setupApplicationDesc(ApplicationDesc appDesc) {
           MDIConfigUtils.setupApplicationDesc(this, "app.properties", appDesc);
         }
         ...
      }
and for the properties file:
      version=0.1
      date=08/10/2023
      name=My Application
      desc=This is an Application with a Description

Using the description description

The application description can be used wherever in your application, including the About dialog.

See also


Categories: general

Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences