Package com.iizigo

Class Activator

    • Constructor Summary

      Constructors 
      ConstructorDescription
      Activator()
      The Eclipse constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidaddServerLaunchOptions​(java.util.ArrayList<java.lang.String> args)
      Adds required options for the server when launched from inside iiziGo.
      static booleanareAllResourceBased​(GProp<?>[] props)
      Checks if the properties only contains resources.
      static voidcenterDialog​(org.eclipse.swt.widgets.Shell shell)
      Centers a dialog box Shell over it's parent.
      static intcheckEnabledOrStarting​(org.eclipse.swt.widgets.Shell shell, org.eclipse.jface.wizard.IWizard wizard)
      Call this function in e.g.
      static intcheckEnabledOrStarting​(org.eclipse.swt.widgets.Shell shell, org.eclipse.jface.wizard.IWizard wizard, java.lang.Runnable runnable)
      Call this function in e.g.
      voidconfigureProxy​(java.net.HttpURLConnection uc)
      Configures a Http(s)URLConnection for proxy information.
      static PropMgrcreateDesignerPropMgr()
      Creates a Property Manager for the Designer connection with JavaScript.
      static org.eclipse.core.runtime.StatuscreateErrorStatus​(java.lang.String msg)
      Creates an error status.
      static org.eclipse.core.runtime.StatuscreateErrorStatus​(java.lang.String msg, java.lang.Throwable e)
      Creates an error status.
      static org.eclipse.core.runtime.StatuscreateInfoStatus​(java.lang.String msg)
      Creates an informational status.
      static byte[]createInputData​(PropCnr container)
      Creates InputStream byte array data from a property container.
      static java.io.InputStreamcreateInputStream​(PropCnr container)
      Creates an InputStream from a property container.
      KStringInfoProviderAdaptercreateKStringInfoProvider​(GProp<?> anyProp, boolean shouldResolve)
      Creates an IKStringInfoProvider for a property.
      static PropFactorycreateNewServerPropertyFactory()
      Creates a new Server property factory.
      static PropMgrcreateServerPropMgr​(boolean hasJSClient)
      Creates a new Property Manager for a Server simulation.
      static org.eclipse.core.runtime.StatuscreateWarningStatus​(java.lang.String msg)
      Creates a warning status.
      static DesignerPropdataToFile​(DesignerProp dp)
      Converts the DesignerProp from the data container to the FilePropCnr one, if it refers to a file.
      static GProp<?>dataToFile​(GProp<?> gp)
      Converts the property to get the FilePropCnr instead of the data container property.
      static GProp<?>[]dataToFile​(GProp<?>[] props)
      Converts the array of properties to get the FilePropCnr instead of the data container property.
      static voiddisposeClipboard()
      Disposes of the clipboard.
      static interrorMessageBox​(org.eclipse.swt.widgets.Shell shell, java.lang.String title, java.lang.String msg, org.eclipse.core.runtime.CoreException e)
      Shows an error message box from any thread for an exception.
      static DesignerPropfileToData​(DesignerProp dp)
      Converts the property to get the data container property instead of a FilePropCnr.
      static GProp<?>fileToData​(GProp<?> gp)
      Converts the property to get the data container property instead of a FilePropCnr.
      static GProp<?>[]fileToData​(GProp<?>[] props)
      Converts the array of properties to get the data container property instead of a FilePropCnr.
      static java.lang.StringgetByteSize​(long size)
      Gets a size string in bytes.
      static org.eclipse.swt.dnd.ClipboardgetClipboard()
      Gets the clip board instance for the plug-in.
      static org.osgi.service.prefs.PreferencesgetConfigurationPreferences()
      Gets the iiziGo Configuration Preferences, not stored in the workspace, but with the Eclipse installation.
      static java.util.List<java.net.URL>getCoreClasspathEntries()
      Gets the classpath entries for the iizi Core.
      java.io.FilegetDatabaseDirectory()
      Gets the database directory to use.
      java.io.FilegetDatabaseDirectoryCandidate()
      Gets the database directory candidate to use.
      static java.util.concurrent.ExecutorServicegetExecutorService()
      Gets the executor service.
      static org.eclipse.core.resources.IFilegetFirstSelectedFile​(org.eclipse.jface.viewers.IStructuredSelection selection)
      Gets the first selected file resource.
      static DesignerPropgetFirstSelectedProperty()
      Gets the first currently selected property.
      static DesignerPropgetFirstSelectedProperty​(org.eclipse.jface.viewers.ISelection sel)
      Gets the first currently selected property.
      static ActivatorgetInstance()
      Returns the shared instance.
      static intgetInternalWebServerUnsecurePort()
      Returns the current HTTP port for the internal web server.
      static java.io.FilegetJDBCDriversDir()
      Gets the JDBC drivers directory, a user local directory that always should exist.
      IKStringInfoProvidergetKStringInfoProvider()
      Retrieves the KStringInfoProvider.
      static java.util.List<java.net.URL>getPluginClasspathEntries()
      Gets the classpath entries for iizi Plug-ins.
      static PropCnr[]getPropCnrs​(java.util.ArrayList<DesignerProp> list)
      Gets a PropCnr's from a DesignerProp list.
      java.net.ProxygetProxy​(java.net.URL url)
      Gets a Java Proxy instance for an URL.
      static PropCnrgetRootProperty​(java.lang.String name)
      Gets a root property from a registered name.
      static IRuntimeBuildergetRuntimeCreation()
      Gets the runtime creation builder.
      static GProp<?>[]getSelectedGProps​(org.eclipse.jface.viewers.ISelection sel)
      Gets a list of all GProp's for DesignerProp's in a selection that should be used in e.g.
      static org.eclipse.core.resources.IProjectgetSelectedProject()
      Gets the currently selected project.
      static org.eclipse.core.resources.IProjectgetSelectedProject​(org.eclipse.jface.viewers.ISelection sel)
      Gets the currently selected project.
      static java.util.ArrayList<DesignerProp>getSelectedProps​(org.eclipse.jface.viewers.ISelection sel)
      Gets a list of all DesignerProp's in a selection that should be used in e.g.
      static java.util.ArrayList<GProp<?>>getSelectedRawGProps​(org.eclipse.jface.viewers.ISelection sel)
      Gets a list of all RAW GProp's without DesignerProp's in a selection that should be used in e.g.
      static org.eclipse.core.resources.IResource[]getSelectedResources()
      Returns the resource selection from the LocalSelectionTransfer.
      static org.eclipse.core.resources.IResource[]getSelectedResources​(org.eclipse.jface.viewers.ISelection selection)
      Returns the resource selection.
      static org.eclipse.core.resources.IResource[]getSelectedResources​(org.eclipse.jface.viewers.IStructuredSelection selection)
      Returns the resource selection.
      static PropFactorygetServerPropertyFactory()
      Gets the Server property factory.
      static org.eclipse.swt.widgets.ShellgetSomeShell()
      Gets a shell.
      static java.io.FilegetStateLocationFile​(java.lang.String fileName)
      Gets a file in the state location area.
      static java.io.FilegetUserPrivateDirectory()
      Gets the user's private directory, normally where the other directories are placed, such as the JDBC drivers "jdbc-drivers", the database "db", etc.
      static WorkergetWorker()
      Gets the Worker.
      static booleanisEnabled()
      Returns if iizi is enabled or not.
      static booleanisResourceBased​(GProp<?> gp)
      Checks if the property contains a resource.
      static booleanisStartingUp()
      Checks if iizi is currently starting up.
      static PropCnrloadPropertiesFile​(java.io.File file)
      Loads a properties file.
      static PropCnrloadPropertiesFile​(java.net.URL url)
      Loads a properties file.
      static PropCnrloadPropertiesFile​(org.eclipse.core.resources.IFile file)
      Loads a properties file.
      static voidmergeStatus​(org.eclipse.core.runtime.MultiStatus status, org.eclipse.core.runtime.IStatus toMerge)
      Adds the given status to the list of problems.
      static intmessageBox​(java.lang.String title, java.lang.String msg, int style)
      Shows a message box.
      static intmessageBox​(org.eclipse.swt.widgets.Shell shell, java.lang.String title, java.lang.String msg, int style)
      Shows a message box.
      static voidmessageBoxAsync​(java.lang.String title, java.lang.String msg, int style)
      Shows a message box asynchronously in the SWT Thread.
      static voidopenError​(java.lang.String genericTitle, java.lang.String errorMsg)
      Opens an error dialog if necessary.
      static voidopenError​(java.lang.String genericTitle, java.lang.String error, java.lang.Throwable exception)
      Opens an error dialog if necessary.
      static voidopenError​(java.lang.String genericTitle, org.eclipse.core.runtime.CoreException exception)
      Opens an error dialog if necessary.
      static voidopenError​(java.lang.String genericTitle, org.eclipse.core.runtime.IStatus status)
      Opens an error dialog if necessary.
      static voidopenError​(org.eclipse.swt.widgets.Shell shell, java.lang.String genericTitle, java.lang.String error)
      Opens an error dialog if necessary.
      static voidopenError​(org.eclipse.swt.widgets.Shell shell, java.lang.String genericTitle, java.lang.String error, java.lang.Throwable exception)
      Opens an error dialog if necessary.
      static voidopenError​(org.eclipse.swt.widgets.Shell shell, java.lang.String genericTitle, org.eclipse.core.runtime.CoreException exception)
      Opens an error dialog if necessary.
      static voidopenError​(org.eclipse.swt.widgets.Shell shell, java.lang.String genericTitle, org.eclipse.core.runtime.IStatus status)
      Opens an error dialog if necessary.
      static voidopenExceptionDetailsError​(org.eclipse.swt.widgets.Shell shell, java.lang.String genericTitle, org.eclipse.core.runtime.IStatus status)
      Opens an error dialog if necessary.
      static voidopenURL​(org.eclipse.swt.widgets.Shell shell, java.lang.String url)
      Opens an URL in an external browser.
      static voidprepareFolder​(org.eclipse.core.resources.IFolder folder, org.eclipse.core.runtime.IProgressMonitor monitor)
      Prepares a folder, i.e.
      static voidrefresh​(java.util.Collection<DesignerProp> dps)
      Refreshes the workspace for the specified properties.
      static booleanregisterRootProperty​(java.lang.String name, PropCnr root)
      Registers a root property container not being a Java or Module root, e.g.
      static voidsavePropertiesFile​(PropCnr container, org.eclipse.core.resources.IFile file, org.eclipse.core.runtime.IProgressMonitor monitor)
      Saves a properties file.
      static voidsetEnabled​(boolean isEnabled)
      Assigns the enabled state of iizi.
      static voidsetRuntimeCreation​(IRuntimeBuilder impl)
      Sets the runtime creation builder.
      voidstart​(org.osgi.framework.BundleContext context)
      Starts up the iiziGo plug-in bundle.
      static intstatusMessageBox​(org.eclipse.swt.widgets.Shell shell, java.lang.String title, java.lang.String msg, org.eclipse.core.runtime.IStatus status)
      Shows a message box from any thread.
      voidstop​(org.osgi.framework.BundleContext context) 
      static intthreadMessageBox​(java.lang.String title, java.lang.String msg, int style)
      Shows a message box from another thread.
      static intthreadMessageBox​(org.eclipse.swt.widgets.Shell shell, java.lang.String title, java.lang.String msg, int style)
      Shows a message box from another thread.
      static booleanunregisterRootProperty​(java.lang.String name, PropCnr root)
      Unregisters a root property container not being a Java or Module root, e.g.
      • Methods inherited from class org.eclipse.ui.plugin.AbstractUIPlugin

        createImageRegistry, getDialogSettings, getImageRegistry, getPreferenceStore, getWorkbench, imageDescriptorFromPlugin, initializeDefaultPluginPreferences, initializeDefaultPreferences, initializeImageRegistry, loadDialogSettings, loadPreferenceStore, refreshPluginActions, saveDialogSettings, savePreferenceStore, shutdown, startup
      • Methods inherited from class org.eclipse.core.runtime.Plugin

        find, find, getBundle, getLog, getPluginPreferences, getStateLocation, internalInitializeDefaultPluginPreferences, isDebugging, openStream, openStream, savePluginPreferences, setDebugging, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        protected static final long serialVersionUID
        The serial UID.
        See Also:
        Constant Field Values
      • PLUGIN_ID

        public static final java.lang.String PLUGIN_ID
        The plug-in ID: "com.iizigo" as in package name for this class.
        See Also:
        Constant Field Values
      • NO_RESOURCES

        public static final org.eclipse.core.resources.IResource[] NO_RESOURCES
        An empty resource array.
      • EMPTY_GPROPS

        public static final GProp<?>[] EMPTY_GPROPS
        The empty array.
      • RESOURCE_CLASS

        public static final java.lang.Class<?> RESOURCE_CLASS
        The resource class.
      • designerFactory

        public static final PropFactory designerFactory
        The Designer property factory.
      • designerPropertyManager

        public static final PropMgr designerPropertyManager
        The Property Manager for the Designer.
      • fileURLResolver

        public static IFileURLResolver fileURLResolver
        Interface used to resolve URL's to files for the Designer. In other products, the same URL is returned unchanged.
    • Constructor Detail

      • Activator

        public Activator()
        The Eclipse constructor.
    • Method Detail

      • isEnabled

        public static boolean isEnabled()
        Returns if iizi is enabled or not.
        Returns:
        true if iizi is enabled, false otherwise.
      • isStartingUp

        public static boolean isStartingUp()
        Checks if iizi is currently starting up.
        Returns:
        true if iizi is still starting up, false if ready.
      • setEnabled

        public static void setEnabled​(boolean isEnabled)
        Assigns the enabled state of iizi.
        Parameters:
        isEnabled - The enabled state.
        Throws:
        java.lang.IllegalStateException - If state is already set.
      • checkEnabledOrStarting

        public static int checkEnabledOrStarting​(org.eclipse.swt.widgets.Shell shell,
                                                 org.eclipse.jface.wizard.IWizard wizard)
        Call this function in e.g. wizards to check if iizi is enabled. A dialog box showing that iizi is not enabled or starting up will be shown, then the runnable is called. The runnable should close e.g. the wizard in question. The runnable will be called in the SWT thread in the "next cycle".
        Parameters:
        shell - The shell.
        wizard - The wizard.
        Returns:
        1 if enabled, 0 (zero) if disabled, -1 if starting up.
      • checkEnabledOrStarting

        public static int checkEnabledOrStarting​(org.eclipse.swt.widgets.Shell shell,
                                                 org.eclipse.jface.wizard.IWizard wizard,
                                                 java.lang.Runnable runnable)
        Call this function in e.g. wizards to check if iizi is enabled. A dialog box showing that iizi is not enabled or starting up will be shown, then the runnable is called. The runnable should close e.g. the wizard in question. The runnable will be called in the SWT thread in the "next cycle".
        Parameters:
        shell - The shell.
        wizard - The wizard.
        runnable - Optional runnable to call. If non-null, the runnable must close the wizard.
        Returns:
        1 if enabled, 0 (zero) if disabled, -1 if starting up.
      • getRuntimeCreation

        public static IRuntimeBuilder getRuntimeCreation()
        Gets the runtime creation builder.
        Returns:
        The runtime builder instance, null if not yet set.
      • setRuntimeCreation

        public static void setRuntimeCreation​(IRuntimeBuilder impl)
        Sets the runtime creation builder. Do not call this method, it is used by the framework.
        Parameters:
        impl - The runtime builder.
      • getCoreClasspathEntries

        public static java.util.List<java.net.URL> getCoreClasspathEntries()
        Gets the classpath entries for the iizi Core.
        Returns:
        The list of core class path entry URL's.
      • getPluginClasspathEntries

        public static java.util.List<java.net.URL> getPluginClasspathEntries()
        Gets the classpath entries for iizi Plug-ins. These entries must also include the Server class entries.
        Returns:
        The list of plugin class path entry URL's.
      • getUserPrivateDirectory

        public static java.io.File getUserPrivateDirectory()
        Gets the user's private directory, normally where the other directories are placed, such as the JDBC drivers "jdbc-drivers", the database "db", etc.
        Returns:
        The User's private directory "~/.iizi/db" in canonical form, the directory is always present.
      • getJDBCDriversDir

        public static java.io.File getJDBCDriversDir()
        Gets the JDBC drivers directory, a user local directory that always should exist.
        Returns:
        The canonical form of the directory "~/.iizi/jdbc-drivers".
      • getDatabaseDirectoryCandidate

        public java.io.File getDatabaseDirectoryCandidate()
        Gets the database directory candidate to use. This call also updates the default value "db_dir" in the Eclipse preference store, if not set.
        Returns:
        The directory to use.
      • getDatabaseDirectory

        public java.io.File getDatabaseDirectory()
                                          throws java.io.IOException
        Gets the database directory to use. The database directory is created if not present.
        Returns:
        The directory to use.
        Throws:
        java.io.IOException - If the database directory failed to be created. In case of an exception, a SEVERE error is logged prior to returning from this method, so no additional logging is required.
      • addServerLaunchOptions

        public void addServerLaunchOptions​(java.util.ArrayList<java.lang.String> args)
                                    throws org.eclipse.core.runtime.CoreException
        Adds required options for the server when launched from inside iiziGo.
        Parameters:
        args - The list of server arguments.
        Throws:
        org.eclipse.core.runtime.CoreException - For errors.
      • getByteSize

        public static java.lang.String getByteSize​(long size)
        Gets a size string in bytes.
        Parameters:
        size - The size.
        Returns:
        The string formatted as "#,##0 bytes".
      • openURL

        public static void openURL​(org.eclipse.swt.widgets.Shell shell,
                                   java.lang.String url)
        Opens an URL in an external browser. If the browser cannot be opened, a message box is displayed. This method may be called from any thread.
        Parameters:
        shell - The shell owner, null for none.
        url - The URL to display.
      • start

        public void start​(org.osgi.framework.BundleContext context)
                   throws java.lang.Exception
        Starts up the iiziGo plug-in bundle.

        If this method throws an exception, it is taken as an indication that plug-in initialization has failed; as a result, the plug-in will not be activated; moreover, the plug-in will be marked as disabled and ineligible for activation for the duration.

        Note 1: This method is automatically invoked by the platform the first time any code in the plug-in is executed.

        Note 2: This method is intended to perform simple initialization of the plug-in environment. The platform may terminate initializers that do not complete in a timely fashion.

        Note 3: The class loader typically has monitors acquired during invocation of this method. It is strongly recommended that this method avoid synchronized blocks or other thread locking mechanisms, as this would lead to deadlock vulnerability.

        Note 4: The supplied bundle context represents the plug-in to the OSGi framework. For security reasons, it is strongly recommended that this object should not be divulged.

        Note 5: This method and the stop(BundleContext) may be called from separate threads, but the OSGi framework ensures that both methods will not be called simultaneously.

        Specified by:
        start in interface org.osgi.framework.BundleActivator
        Overrides:
        start in class org.eclipse.ui.plugin.AbstractUIPlugin
        Parameters:
        context - The bundle context.
        Throws:
        java.lang.Exception - For errors in loading the iizi properties framework.
      • stop

        public void stop​(org.osgi.framework.BundleContext context)
                  throws java.lang.Exception
        Specified by:
        stop in interface org.osgi.framework.BundleActivator
        Overrides:
        stop in class org.eclipse.ui.plugin.AbstractUIPlugin
        Throws:
        java.lang.Exception
      • getWorker

        public static Worker getWorker()
                                throws java.io.IOException
        Gets the Worker.
        Returns:
        The worker, never null.
        Throws:
        java.io.IOException - If the worker cannot be started.
      • createDesignerPropMgr

        public static PropMgr createDesignerPropMgr()
        Creates a Property Manager for the Designer connection with JavaScript.
        Returns:
        The newly created PropMgr instance using Server and JavaScript mappings.
      • createServerPropMgr

        public static PropMgr createServerPropMgr​(boolean hasJSClient)
        Creates a new Property Manager for a Server simulation.
        Parameters:
        hasJSClient - Flag indicating it's a JavaScript client or not.
        Returns:
        The Property Manager or null if instance failed (errors are logged already).
      • createNewServerPropertyFactory

        public static PropFactory createNewServerPropertyFactory()
                                                          throws java.io.IOException
        Creates a new Server property factory.
        Returns:
        The newly created property factory.
        Throws:
        java.io.IOException - For failures.
      • getServerPropertyFactory

        public static PropFactory getServerPropertyFactory()
        Gets the Server property factory.
        Returns:
        The server property factory, always the same instance once created.
      • registerRootProperty

        public static boolean registerRootProperty​(java.lang.String name,
                                                   PropCnr root)
        Registers a root property container not being a Java or Module root, e.g. Terminal Sessions.
        Parameters:
        name - The name.
        root - The root instance.
        Returns:
        true For success, false (with logged warning message) indicates name is already registered.
        Throws:
        java.lang.IllegalArgumentException - If it's not a root property.
      • getRootProperty

        public static PropCnr getRootProperty​(java.lang.String name)
        Gets a root property from a registered name.
        Parameters:
        name - The name.
        Returns:
        The root property, or null if not registered.
      • unregisterRootProperty

        public static boolean unregisterRootProperty​(java.lang.String name,
                                                     PropCnr root)
        Unregisters a root property container not being a Java or Module root, e.g. Terminal Sessions.
        Parameters:
        name - The name.
        root - The root instance.
        Returns:
        true For success, false (with logged warning message) indicates name is not registered.
        Throws:
        java.lang.IllegalArgumentException - If it's not a root property.
      • getStateLocationFile

        public static java.io.File getStateLocationFile​(java.lang.String fileName)
        Gets a file in the state location area.
        Parameters:
        fileName - The file name, set to null to get the (parent) directory where state files are stored.
        Returns:
        The file for the activator plugin, or null if not initialized or exiting.
      • getSomeShell

        public static org.eclipse.swt.widgets.Shell getSomeShell()
        Gets a shell.
        Returns:
        Some shell.
      • messageBoxAsync

        public static void messageBoxAsync​(java.lang.String title,
                                           java.lang.String msg,
                                           int style)
        Shows a message box asynchronously in the SWT Thread. If the call is from a non-SWT thread, a switch to the SWT thread is done.
        Parameters:
        title - The title.
        msg - The message.
        style - The SWT style, icons, buttons, etc.
      • messageBox

        public static int messageBox​(java.lang.String title,
                                     java.lang.String msg,
                                     int style)
        Shows a message box. If the call is from a non-SWT thread, a switch to the SWT thread is done.
        Parameters:
        title - The title.
        msg - The message.
        style - The SWT style, icons, buttons, etc.
        Returns:
        The button selected.
      • messageBox

        public static int messageBox​(org.eclipse.swt.widgets.Shell shell,
                                     java.lang.String title,
                                     java.lang.String msg,
                                     int style)
        Shows a message box.
        Parameters:
        shell - The shell (owner of message box).
        title - The title.
        msg - The message.
        style - The SWT style, icons, buttons, etc.
        Returns:
        The button selected.
      • threadMessageBox

        public static int threadMessageBox​(java.lang.String title,
                                           java.lang.String msg,
                                           int style)
        Shows a message box from another thread.
        Parameters:
        msg - The message.
        title - The title.
        style - The SWT style, icons, buttons, etc.
        Returns:
        The button selected.
      • threadMessageBox

        public static int threadMessageBox​(org.eclipse.swt.widgets.Shell shell,
                                           java.lang.String title,
                                           java.lang.String msg,
                                           int style)
        Shows a message box from another thread.
        Parameters:
        shell - The shell or null for none.
        msg - The message.
        title - The title.
        style - The SWT style, icons, buttons, etc.
        Returns:
        The button selected.
      • openError

        public static void openError​(java.lang.String genericTitle,
                                     org.eclipse.core.runtime.CoreException exception)
        Opens an error dialog if necessary. Takes care of complex rules necessary for making the error dialog look nice.

        This call can be done from any thread, if not the SWT thread, it will "syncExec" to it.

        Parameters:
        genericTitle - The title, or null to use "Error".
        exception - The core exception.
      • openError

        public static void openError​(java.lang.String genericTitle,
                                     java.lang.String errorMsg)
        Opens an error dialog if necessary. Takes care of complex rules necessary for making the error dialog look nice.

        This call can be done from any thread, if not the SWT thread, it will "syncExec" to it.

        Parameters:
        genericTitle - The title, or null to use "Error".
        errorMsg - Error message.
      • openError

        public static void openError​(org.eclipse.swt.widgets.Shell shell,
                                     java.lang.String genericTitle,
                                     org.eclipse.core.runtime.CoreException exception)
        Opens an error dialog if necessary. Takes care of complex rules necessary for making the error dialog look nice.

        This call can be done from any thread, if not the SWT thread, it will "syncExec" to it.

        Parameters:
        shell - The shell, or null to get the topmost one.
        genericTitle - The title, or null to use "Error".
        exception - The core exception.
      • openError

        public static void openError​(java.lang.String genericTitle,
                                     org.eclipse.core.runtime.IStatus status)
        Opens an error dialog if necessary. Takes care of complex rules necessary for making the error dialog look nice.

        This call can be done from any thread, if not the SWT thread, it will "syncExec" to it.

        Parameters:
        genericTitle - The title, or null to use "Error".
        status - The status.
      • openError

        public static void openError​(java.lang.String genericTitle,
                                     java.lang.String error,
                                     java.lang.Throwable exception)
        Opens an error dialog if necessary. Takes care of complex rules necessary for making the error dialog look nice.
        Parameters:
        genericTitle - The title, or null to use "Error".
        error - The error message.
        exception - The exception.
      • openError

        public static void openError​(org.eclipse.swt.widgets.Shell shell,
                                     java.lang.String genericTitle,
                                     java.lang.String error)
        Opens an error dialog if necessary. Takes care of complex rules necessary for making the error dialog look nice.

        This call can be done from any thread, if not the SWT thread, it will "syncExec" to it.

        Parameters:
        shell - The shell, or null to get the topmost one.
        genericTitle - The title, or null to use "Error".
        error - The error message.
      • openError

        public static void openError​(org.eclipse.swt.widgets.Shell shell,
                                     java.lang.String genericTitle,
                                     java.lang.String error,
                                     java.lang.Throwable exception)
        Opens an error dialog if necessary. Takes care of complex rules necessary for making the error dialog look nice.

        This call can be done from any thread, if not the SWT thread, it will "syncExec" to it.

        Parameters:
        shell - The shell, or null to get the topmost one.
        genericTitle - The title, or null to use "Error".
        error - The error message.
        exception - The exception.
      • openError

        public static void openError​(org.eclipse.swt.widgets.Shell shell,
                                     java.lang.String genericTitle,
                                     org.eclipse.core.runtime.IStatus status)
        Opens an error dialog if necessary. Takes care of complex rules necessary for making the error dialog look nice.

        This call can be done from any thread, if not the SWT thread, it will "syncExec" to it.

        Parameters:
        shell - The shell, or null to get the topmost one.
        genericTitle - The title, or null to use "Error".
        status - The status.
      • openExceptionDetailsError

        public static void openExceptionDetailsError​(org.eclipse.swt.widgets.Shell shell,
                                                     java.lang.String genericTitle,
                                                     org.eclipse.core.runtime.IStatus status)
        Opens an error dialog if necessary. Takes care of complex rules necessary for making the error dialog look nice.

        This call can be done from any thread, if not the SWT thread, it will "syncExec" to it.

        Parameters:
        shell - The shell, or null to get the topmost one.
        genericTitle - The title, or null to use "Error".
        status - The status.
      • errorMessageBox

        public static int errorMessageBox​(org.eclipse.swt.widgets.Shell shell,
                                          java.lang.String title,
                                          java.lang.String msg,
                                          org.eclipse.core.runtime.CoreException e)
        Shows an error message box from any thread for an exception.
        Parameters:
        shell - The shell to use, if null one will be found...
        title - The title.
        msg - The message.
        e - The Core Exception.
        Returns:
        The code of the button that was pressed that resulted in this dialog closing. This will be Dialog.OK if the OK button was pressed, or Dialog.CANCEL if this dialog's close window decoration or the ESC key was used.
      • statusMessageBox

        public static int statusMessageBox​(org.eclipse.swt.widgets.Shell shell,
                                           java.lang.String title,
                                           java.lang.String msg,
                                           org.eclipse.core.runtime.IStatus status)
        Shows a message box from any thread.
        Parameters:
        shell - The shell to use, if null one will be found...
        title - The title.
        msg - The message.
        status - The IStatus message (also MultiStatus).
        Returns:
        The code of the button that was pressed that resulted in this dialog closing. This will be Dialog.OK if the OK button was pressed, or Dialog.CANCEL if this dialog's close window decoration or the ESC key was used.
      • getInstance

        public static Activator getInstance()
        Returns the shared instance.
        Returns:
        The shared instance.
      • getProxy

        public java.net.Proxy getProxy​(java.net.URL url)
        Gets a Java Proxy instance for an URL.
        Specified by:
        getProxy in interface IWebServiceEngine
        Parameters:
        url - The URL to get the proxy from.
        Returns:
        The proxy to use.
      • configureProxy

        public void configureProxy​(java.net.HttpURLConnection uc)
        Configures a Http(s)URLConnection for proxy information.
        Specified by:
        configureProxy in interface IWebServiceEngine
        Parameters:
        uc - The HttpURLConnection or HttpsURLConnection.
      • loadPropertiesFile

        public static PropCnr loadPropertiesFile​(java.io.File file)
                                          throws java.io.IOException,
                                                 PropException
        Loads a properties file.
        Parameters:
        file - The file.
        Returns:
        The loaded property container.
        Throws:
        PropException - For property errors.
        java.io.IOException - For I/O errors.
      • loadPropertiesFile

        public static PropCnr loadPropertiesFile​(java.net.URL url)
                                          throws java.io.IOException,
                                                 PropException
        Loads a properties file.
        Parameters:
        url - The URL.
        Returns:
        The loaded property container.
        Throws:
        PropException - For property errors.
        java.io.IOException - For I/O errors.
      • loadPropertiesFile

        public static PropCnr loadPropertiesFile​(org.eclipse.core.resources.IFile file)
                                          throws org.eclipse.core.runtime.CoreException
        Loads a properties file.
        Parameters:
        file - The file.
        Returns:
        The loaded property container.
        Throws:
        org.eclipse.core.runtime.CoreException - For file errors.
      • createInputData

        public static byte[] createInputData​(PropCnr container)
                                      throws java.io.IOException,
                                             javax.xml.transform.TransformerException
        Creates InputStream byte array data from a property container.
        Parameters:
        container - The property container.
        Returns:
        The byte array for the property container.
        Throws:
        java.io.IOException - For I/O errors.
        javax.xml.transform.TransformerException - For XML error.
      • createInputStream

        public static java.io.InputStream createInputStream​(PropCnr container)
                                                     throws java.io.IOException,
                                                            javax.xml.transform.TransformerException
        Creates an InputStream from a property container.
        Parameters:
        container - The property container.
        Returns:
        The InputStream for the property container.
        Throws:
        java.io.IOException - For I/O errors.
        javax.xml.transform.TransformerException - For XML error.
      • savePropertiesFile

        public static void savePropertiesFile​(PropCnr container,
                                              org.eclipse.core.resources.IFile file,
                                              org.eclipse.core.runtime.IProgressMonitor monitor)
                                       throws org.eclipse.core.runtime.CoreException
        Saves a properties file. The IFile reference and the file modification stamp are saved in the property container.
        Parameters:
        container - The property container.
        file - The file.
        monitor - The monitor.
        Throws:
        org.eclipse.core.runtime.CoreException - For Eclipse file system errors.
      • prepareFolder

        public static void prepareFolder​(org.eclipse.core.resources.IFolder folder,
                                         org.eclipse.core.runtime.IProgressMonitor monitor)
                                  throws org.eclipse.core.runtime.CoreException
        Prepares a folder, i.e. makes sure it exists. If not it is created, recursively.
        Parameters:
        folder - The folder to prepare.
        monitor - The progress monitor.
        Throws:
        org.eclipse.core.runtime.CoreException - For folder creation errors.
      • getSelectedProject

        public static org.eclipse.core.resources.IProject getSelectedProject()
        Gets the currently selected project.
        Returns:
        The project, or null if none is selected.
      • getSelectedProject

        public static org.eclipse.core.resources.IProject getSelectedProject​(org.eclipse.jface.viewers.ISelection sel)
        Gets the currently selected project.
        Parameters:
        sel - The structured selection, null for none.
        Returns:
        The project, or null if none is selected.
      • getFirstSelectedProperty

        public static DesignerProp getFirstSelectedProperty()
        Gets the first currently selected property.
        Returns:
        The property, or null if none is selected.
      • getFirstSelectedProperty

        public static DesignerProp getFirstSelectedProperty​(org.eclipse.jface.viewers.ISelection sel)
        Gets the first currently selected property.

        This method validates the properties and skips those that are disposed of in case the viewer selection is "old" and not refreshed.

        Parameters:
        sel - The structured selection, null for none.
        Returns:
        The property, or null if none is selected.
      • getSelectedProps

        public static java.util.ArrayList<DesignerProp> getSelectedProps​(org.eclipse.jface.viewers.ISelection sel)
        Gets a list of all DesignerProp's in a selection that should be used in e.g. a Delete or Copy/Cut operation. If a property container is present in the selection, all its children are removed from the list, because they would be included in the container operation.

        This method validates the properties and skips those that are disposed of in case the viewer selection is "old" and not refreshed.

        Parameters:
        sel - The structured selection, null for none.
        Returns:
        The list of selected properties.
      • getSelectedGProps

        public static GProp<?>[] getSelectedGProps​(org.eclipse.jface.viewers.ISelection sel)
        Gets a list of all GProp's for DesignerProp's in a selection that should be used in e.g. a Delete or Copy/Cut operation. If a property container is present in the selection, all its children are removed from the list, because they would be included in the container operation.
        Parameters:
        sel - The selection.
        Returns:
        The GProp array.
      • getSelectedRawGProps

        public static java.util.ArrayList<GProp<?>> getSelectedRawGProps​(org.eclipse.jface.viewers.ISelection sel)
        Gets a list of all RAW GProp's without DesignerProp's in a selection that should be used in e.g. a Delete or Copy/Cut operation. If a property container is present in the selection, all its children are removed from the list, because they would be included in the container operation.
        Parameters:
        sel - The selection.
        Returns:
        The GProp array.
      • getPropCnrs

        public static PropCnr[] getPropCnrs​(java.util.ArrayList<DesignerProp> list)
        Gets a PropCnr's from a DesignerProp list.
        Parameters:
        list - The list of DesignerProp's or null for none.
        Returns:
        The returned array, never null.
      • isResourceBased

        public static boolean isResourceBased​(GProp<?> gp)
        Checks if the property contains a resource.
        Parameters:
        gp - The property.
        Returns:
        true if the property is a FilePropCnr or FolderPropCnr with a resource.
      • areAllResourceBased

        public static boolean areAllResourceBased​(GProp<?>[] props)
        Checks if the properties only contains resources.
        Parameters:
        props - The properties.
        Returns:
        true if all properties are resource based, false otherwise.
      • fileToData

        public static GProp<?> fileToData​(GProp<?> gp)
        Converts the property to get the data container property instead of a FilePropCnr.
        Parameters:
        gp - The input property.
        Returns:
        The same as the input property for no change, the data container property if it was a FilePropCnr when possible (data container not null).
      • fileToData

        public static DesignerProp fileToData​(DesignerProp dp)
        Converts the property to get the data container property instead of a FilePropCnr.
        Parameters:
        dp - The input property.
        Returns:
        The same as the input property for no change, the data container property if it was a FilePropCnr when possible (data container not null).
      • fileToData

        public static GProp<?>[] fileToData​(GProp<?>[] props)
        Converts the array of properties to get the data container property instead of a FilePropCnr.
        Parameters:
        props - The input properties.
        Returns:
        The same as the input array for no change, a new array without FilePropCnr when possible (data container not null).
      • dataToFile

        public static GProp<?> dataToFile​(GProp<?> gp)
        Converts the property to get the FilePropCnr instead of the data container property.
        Parameters:
        gp - The input propertY.
        Returns:
        The property or its FilePropCnr when possible.
      • dataToFile

        public static DesignerProp dataToFile​(DesignerProp dp)
        Converts the DesignerProp from the data container to the FilePropCnr one, if it refers to a file.
        Parameters:
        dp - The Designer property instance of e.g. the data container.
        Returns:
        The File Designer property if the parameter dp was a data container, otherwise the same value as the dp parameter.
      • dataToFile

        public static GProp<?>[] dataToFile​(GProp<?>[] props)
        Converts the array of properties to get the FilePropCnr instead of the data container property.
        Parameters:
        props - The input properties.
        Returns:
        The same as the input array for no change, a new array with FilePropCnr when possible.
      • getSelectedResources

        public static org.eclipse.core.resources.IResource[] getSelectedResources()
        Returns the resource selection from the LocalSelectionTransfer.
        Returns:
        The currently selected resources, never null.
      • getSelectedResources

        public static org.eclipse.core.resources.IResource[] getSelectedResources​(org.eclipse.jface.viewers.ISelection selection)
        Returns the resource selection.
        Parameters:
        selection - Any selection of properties, resources, etc.
        Returns:
        The resources from a selection, never null.
      • getSelectedResources

        public static org.eclipse.core.resources.IResource[] getSelectedResources​(org.eclipse.jface.viewers.IStructuredSelection selection)
        Returns the resource selection.
        Parameters:
        selection - Any selection of properties, resources, etc.
        Returns:
        The resources from a selection, never null.
      • getFirstSelectedFile

        public static org.eclipse.core.resources.IFile getFirstSelectedFile​(org.eclipse.jface.viewers.IStructuredSelection selection)
        Gets the first selected file resource.
        Parameters:
        selection - The selection.
        Returns:
        The resource or null if none.
      • getClipboard

        public static org.eclipse.swt.dnd.Clipboard getClipboard()
        Gets the clip board instance for the plug-in. It will be disposed of when the plug-in stops.
        Returns:
        The clipboard instance.
      • disposeClipboard

        public static void disposeClipboard()
        Disposes of the clipboard.
      • mergeStatus

        public static void mergeStatus​(org.eclipse.core.runtime.MultiStatus status,
                                       org.eclipse.core.runtime.IStatus toMerge)
        Adds the given status to the list of problems. Discards OK statuses. If the status is a multi-status, only its children are added.
        Parameters:
        status - The status to merge with.
        toMerge - The status to merge, if it's OK to merge!
      • createErrorStatus

        public static org.eclipse.core.runtime.Status createErrorStatus​(java.lang.String msg)
        Creates an error status.
        Parameters:
        msg - The message.
        Returns:
        The status.
      • createErrorStatus

        public static org.eclipse.core.runtime.Status createErrorStatus​(java.lang.String msg,
                                                                        java.lang.Throwable e)
        Creates an error status.
        Parameters:
        msg - The message.
        e - The exception.
        Returns:
        The status.
      • createWarningStatus

        public static org.eclipse.core.runtime.Status createWarningStatus​(java.lang.String msg)
        Creates a warning status.
        Parameters:
        msg - The message.
        Returns:
        The status.
      • createInfoStatus

        public static org.eclipse.core.runtime.Status createInfoStatus​(java.lang.String msg)
        Creates an informational status.
        Parameters:
        msg - The message.
        Returns:
        The status.
      • refresh

        public static void refresh​(java.util.Collection<DesignerProp> dps)
        Refreshes the workspace for the specified properties.
        Parameters:
        dps - The collection of DesignerProp's to refresh.
      • centerDialog

        public static void centerDialog​(org.eclipse.swt.widgets.Shell shell)
        Centers a dialog box Shell over it's parent.
        Parameters:
        shell - The dialog box shell.
      • getInternalWebServerUnsecurePort

        public static int getInternalWebServerUnsecurePort()
        Returns the current HTTP port for the internal web server.
        Returns:
        The port number, or zero if not started.
      • createKStringInfoProvider

        public KStringInfoProviderAdapter createKStringInfoProvider​(GProp<?> anyProp,
                                                                    boolean shouldResolve)
        Creates an IKStringInfoProvider for a property.
        Parameters:
        anyProp - Property for reference resolving.
        shouldResolve - Flag indicating the "real" resolved string should be returned. This value is true for the runtime client when in "real run mode".
        Returns:
        A new KStringInfoProviderAdapter instance for the unsecure web server port if any.
      • getConfigurationPreferences

        public static org.osgi.service.prefs.Preferences getConfigurationPreferences()
        Gets the iiziGo Configuration Preferences, not stored in the workspace, but with the Eclipse installation.

        You may create another node if you wish to separate it from the default iiziGo ones.

        Returns:
        The preferences.
      • getExecutorService

        public static java.util.concurrent.ExecutorService getExecutorService()
        Gets the executor service.
        Returns:
        The executor service instance tunes for this machine.