Class License
- java.lang.Object
-
- com.biomatters.geneious.publicapi.plugin.License
-
public final class License extends java.lang.Object
Provides access to the current Geneious user license state, the names of various versions of Geneious, and support for being notified when the license key status changes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
License.PluginLicense
Represents the properties of a license which is used to activate a "pay-for" plugin or feature.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
addLicenseTypeChangeListener(org.virion.jam.util.SimpleListener listener)
Adds a listener to be notified when the license changes.static void
addWeakLicenseTypeChangeListener(org.virion.jam.util.SimpleListener listener)
This method is identical toaddLicenseTypeChangeListener(org.virion.jam.util.SimpleListener)
except that only aWeakReference
is stored to the listener so that it can be garbage collected when nothing else besides this class refers to it.static java.lang.String
freeVersionName()
Deprecated.the "free" version of Geneious no longer has a name, features are simply restricted when no license is active.static java.lang.String
freeVersionSuffix()
Deprecated.the "free" version of Geneious no longer has a name, features are simply restricted when no license is active.static boolean
hasLicenseBeenSet()
Returns true if the license has been identified and set and it is safe to callisProVersion()
.static boolean
isCommercialUser()
Checks if the currently active license is for a commercial user of the software.static boolean
isPluginLicenseActive(GeneiousPlugin plugin, License.PluginLicense pluginLicense, boolean promptUser)
Check if a trial or purchased license is active for the given plugin license.static boolean
isProVersion()
Checks whether Geneious currently has an active license, eg.static java.lang.String
premiumVersionName()
Deprecated.there never was and there will never be a premium version of Geneious.static java.lang.String
premiumVersionPrefix()
Deprecated.there never was and there will never be a premium version of Geneious.static java.lang.String
proOnlyButtonName(java.lang.String name)
Useful for renaming a feature when there is no license active.static java.lang.String
proOnlyName(java.lang.String name)
Useful for renaming a feature when there is no license active.static java.lang.String
proVersionName()
Deprecated.there is no "Pro" version anymore, Geneious is Geneious.static java.lang.String
proVersionSuffix()
Deprecated.there is no "Pro" version anymore, Geneious is Geneious.static void
removeLicenseTypeChangeListener(org.virion.jam.util.SimpleListener listener)
Removes a listener added using addLicenseTypeChangeListener()static void
removeWeakLicenseTypeChangeListener(org.virion.jam.util.SimpleListener listener)
Removes a listener added usingaddWeakLicenseTypeChangeListener(org.virion.jam.util.SimpleListener)
static java.lang.String
restrictedName(boolean upperCaseR)
The word used to describe Geneious when it doesn't have an active license.
-
-
-
Method Detail
-
isProVersion
public static boolean isProVersion()
Checks whether Geneious currently has an active license, eg. the user has a license key or is running a trial. NOTE: WThis can change at any time while Geneious is running, e.g. when a new license is registered, expires or becomes deactivated by the user or by Geneious (due to cheating detection). It is recommended that operations and viewers respond to license changes as quickly as possible, preferrably without any action from the user (i.e. if the license changes, a viewer should update itself without the user first having to click on another document and back to the original document). To subscribe to license change events (not all of which comprise a change in the return value of this method), calladdLicenseTypeChangeListener
.- Returns:
- true if Geneious currently has an active license
-
hasLicenseBeenSet
public static boolean hasLicenseBeenSet()
Returns true if the license has been identified and set and it is safe to callisProVersion()
.Some features which run before Geneious is initialized (such as the CLI) may need to check this as a license may not have been checked and set yet.
- Returns:
- true if the license has been set, false otherwise.
- Since:
- API 4.202220 (Geneious 2022.2.0)
-
isCommercialUser
public static boolean isCommercialUser()
Checks if the currently active license is for a commercial user of the software.- Returns:
- true if currently active license is for a commercial user, false if license is for a non-commercial user (eg. academic, government, student)
- Since:
- API 4.600 (Geneious 6.0.0)
-
isPluginLicenseActive
public static boolean isPluginLicenseActive(GeneiousPlugin plugin, License.PluginLicense pluginLicense, boolean promptUser)
Check if a trial or purchased license is active for the given plugin license. Can also prompt the user if they need a license, giving them an option to activate a license or start a trial if available. If this returns false then the plugin can cancel the current action to prevent it's use without an active license. IMPORTANT: Any license passed in to this method must also be returned by the plugin fromGeneiousPlugin.getPluginLicenses()
For example: To make your plugin prompt about requiring a license when it is first installed, add the following code to your plugins initialize method.- Parameters:
plugin
- the plugin that is checking. must not be nullpluginLicense
- provides details of the license and trial to check. must not be nullpromptUser
- if true then the user will be shown a dialog when either no license is presence or only an expired trial/license is present. No dialog is shown if this is false or a license is active.- Returns:
- true if a license is available, false if not
- Since:
- API 4.40 (Geneious 5.4)
-
restrictedName
public static java.lang.String restrictedName(boolean upperCaseR)
The word used to describe Geneious when it doesn't have an active license.- Parameters:
upperCaseR
- true if restricted should start with a upper case R, false for lower case- Returns:
- the String "restricted" or "Restricted" depending on upperCaseR parameter
- Since:
- API 4.600 (Geneious 6.0)
-
proVersionSuffix
@Deprecated public static java.lang.String proVersionSuffix()
Deprecated.there is no "Pro" version anymore, Geneious is Geneious. Consider usingrestrictedName(boolean)
instead. Deprecated in API 4.600 (Geneious 6.0.0)The suffix to append toGeneious.getName()
(separated by a space) in order to obtain the name that distinctively identifies the Pro version of Geneious.- Returns:
- the suffix of the pro version. Useful for appending to the name of features that are only available in the pro version.
-
freeVersionSuffix
@Deprecated public static java.lang.String freeVersionSuffix()
Deprecated.the "free" version of Geneious no longer has a name, features are simply restricted when no license is active. Deprecated in API 4.600 (Geneious 6.0.0)- Returns:
- the suffix of the free version.
- See Also:
restrictedName(boolean)
-
freeVersionName
@Deprecated public static java.lang.String freeVersionName()
Deprecated.the "free" version of Geneious no longer has a name, features are simply restricted when no license is active. Deprecated in API 4.600 (Geneious 6.0.0)- Returns:
- The name of the free version of Geneious
- See Also:
restrictedName(boolean)
-
proVersionName
@Deprecated public static java.lang.String proVersionName()
Deprecated.there is no "Pro" version anymore, Geneious is Geneious. Consider usingGeneious.getName()
instead. Deprecated in API 4.600 (Geneious 6.0.0)- Returns:
- the name of the pro version of Geneious
-
premiumVersionPrefix
@Deprecated public static java.lang.String premiumVersionPrefix()
Deprecated.there never was and there will never be a premium version of Geneious. Deprecated in API 4.600 (Geneious 6.0.0)- Returns:
- the prefix of the premium version.
-
premiumVersionName
@Deprecated public static java.lang.String premiumVersionName()
Deprecated.there never was and there will never be a premium version of Geneious. Deprecated in API 4.600 (Geneious 6.0.0)- Returns:
- the name of the premium version of Geneious
-
proOnlyName
public static java.lang.String proOnlyName(java.lang.String name)
Useful for renaming a feature when there is no license active.- Parameters:
name
- the normal name of the feature, eg. "Cloning"- Returns:
- name if isProVersion() is true, otherwise name + " (restricted)"
-
proOnlyButtonName
public static java.lang.String proOnlyButtonName(java.lang.String name)
Useful for renaming a feature when there is no license active. The same as callingproOnlyName(String)
- Parameters:
name
- the normal name of the feature, eg. "Cloning"- Returns:
- name if isProVersion() is true, otherwise name + " (restricted)"
-
addLicenseTypeChangeListener
public static void addLicenseTypeChangeListener(org.virion.jam.util.SimpleListener listener)
Adds a listener to be notified when the license changes. This will happen e.g. when the user enters the license key, or when the user temporarily enables a trial. Note that not every license change means the return value ofisProVersion()
has changed, so you will still need to queryisProVersion
when you are notified that a change has happened. WARNING: This method should almost never be used as it will likely cause memory leaks. UseaddWeakLicenseTypeChangeListener
instead- Parameters:
listener
- the listener to be notified when the license type changes- See Also:
removeLicenseTypeChangeListener(org.virion.jam.util.SimpleListener)
,addWeakLicenseTypeChangeListener(org.virion.jam.util.SimpleListener)
-
removeLicenseTypeChangeListener
public static void removeLicenseTypeChangeListener(org.virion.jam.util.SimpleListener listener)
Removes a listener added using addLicenseTypeChangeListener()- Parameters:
listener
- listener to remove
-
removeWeakLicenseTypeChangeListener
public static void removeWeakLicenseTypeChangeListener(org.virion.jam.util.SimpleListener listener)
Removes a listener added usingaddWeakLicenseTypeChangeListener(org.virion.jam.util.SimpleListener)
- Parameters:
listener
- the listener to be removed
-
addWeakLicenseTypeChangeListener
public static void addWeakLicenseTypeChangeListener(org.virion.jam.util.SimpleListener listener)
This method is identical toaddLicenseTypeChangeListener(org.virion.jam.util.SimpleListener)
except that only aWeakReference
is stored to the listener so that it can be garbage collected when nothing else besides this class refers to it.- Parameters:
listener
- listener to add
-
-