Class CreateResourcesFromProperties

  • All Implemented Interfaces:
    org.eclipse.core.commands.operations.IUndoableOperation

    public class CreateResourcesFromProperties
    extends org.eclipse.core.commands.operations.AbstractOperation
    Class used to create resources from properties, with undo support.
    Author:
    Christopher Mindus
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      static java.lang.StringcreateFile​(org.eclipse.swt.widgets.Shell shell, java.lang.String label, org.eclipse.core.resources.IContainer folder, PropCnr cnr, java.lang.String fileName, boolean doOverwrite)
      Creates a resource file for a property with undo support.
      static java.lang.StringcreateFile​(org.eclipse.swt.widgets.Shell shell, java.lang.String label, org.eclipse.core.resources.IContainer folder, PropCnr cnr, java.lang.String fileName, boolean doOverwrite, boolean showErrorDialog)
      Creates a resource file for a property with undo support.
      static java.lang.StringcreateResources​(org.eclipse.swt.widgets.Shell shell, java.lang.String label, DesignerProp parent, GProp<?>[] props, java.lang.String[] names)
      Creates the resources for the list of properties in the specified property.
      static java.lang.StringcreateResources​(org.eclipse.swt.widgets.Shell shell, java.lang.String label, DesignerProp parent, GProp<?>[] props, java.lang.String[] names, boolean showErrorDialog)
      Creates the resources for the list of properties in the specified property.
      org.eclipse.core.runtime.IStatusexecute​(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)
      Execute the operation.
      org.eclipse.core.runtime.IStatusredo​(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)
      Redo the operation.
      org.eclipse.core.runtime.IStatusundo​(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)
      Undo the operation.
      • Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation

        addContext, canExecute, canRedo, canUndo, dispose, getContexts, getLabel, hasContext, removeContext, setLabel, toString
      • Methods inherited from class java.lang.Object

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

      • execute

        public org.eclipse.core.runtime.IStatus execute​(org.eclipse.core.runtime.IProgressMonitor monitor,
                                                        org.eclipse.core.runtime.IAdaptable info)
                                                 throws org.eclipse.core.commands.ExecutionException
        Execute the operation. This method should only be called the first time that an operation is executed.
        Specified by:
        execute in interface org.eclipse.core.commands.operations.IUndoableOperation
        Specified by:
        execute in class org.eclipse.core.commands.operations.AbstractOperation
        Parameters:
        monitor - The progress monitor (or null) to use for reporting progress to the user.
        info - The IAdaptable (or null) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is not null, it should minimally contain an adapter for the org.eclipse.swt.widgets.Shell.class.
        Returns:
        the IStatus of the execution. The status severity should be set to OK if the operation was successful, and ERROR if it was not. Any other status is assumed to represent an incompletion of the execution.
        Throws:
        org.eclipse.core.commands.ExecutionException - Tf an exception occurred during execution.
      • redo

        public org.eclipse.core.runtime.IStatus redo​(org.eclipse.core.runtime.IProgressMonitor monitor,
                                                     org.eclipse.core.runtime.IAdaptable info)
                                              throws org.eclipse.core.commands.ExecutionException
        Redo the operation. This method should only be called after an operation has been undone.
        Specified by:
        redo in interface org.eclipse.core.commands.operations.IUndoableOperation
        Specified by:
        redo in class org.eclipse.core.commands.operations.AbstractOperation
        Parameters:
        monitor - The progress monitor (or null) to use for reporting progress to the user.
        info - The IAdaptable (or null) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is not null, it should minimally contain an adapter for the org.eclipse.swt.widgets.Shell.class.
        Returns:
        The IStatus of the redo. The status severity should be set to OK if the redo was successful, and ERROR if it was not. Any other status is assumed to represent an incompletion of the redo.
        Throws:
        org.eclipse.core.commands.ExecutionException - If an exception occurred during redo.
      • undo

        public org.eclipse.core.runtime.IStatus undo​(org.eclipse.core.runtime.IProgressMonitor monitor,
                                                     org.eclipse.core.runtime.IAdaptable info)
                                              throws org.eclipse.core.commands.ExecutionException
        Undo the operation. This method should only be called after an operation has been executed.
        Specified by:
        undo in interface org.eclipse.core.commands.operations.IUndoableOperation
        Specified by:
        undo in class org.eclipse.core.commands.operations.AbstractOperation
        Parameters:
        monitor - The progress monitor (or null) to use for reporting progress to the user.
        info - The IAdaptable (or null) provided by the caller in order to supply UI information for prompting the user if necessary. When this parameter is not null, it should minimally contain an adapter for the org.eclipse.swt.widgets.Shell.class.
        Returns:
        The IStatus of the undo. The status severity should be set to OK if the redo was successful, and ERROR if it was not. Any other status is assumed to represent an incompletion of the undo.
        Throws:
        org.eclipse.core.commands.ExecutionException - If an exception occurred during undo.
      • createResources

        public static java.lang.String createResources​(org.eclipse.swt.widgets.Shell shell,
                                                       java.lang.String label,
                                                       DesignerProp parent,
                                                       GProp<?>[] props,
                                                       java.lang.String[] names)
        Creates the resources for the list of properties in the specified property.
        Parameters:
        shell - The shell.
        parent - The parent property.
        props - The properties to create.
        names - The new (or existing) names of the properties.
        Returns:
        null for OK, otherwise an error message.
      • createResources

        public static java.lang.String createResources​(org.eclipse.swt.widgets.Shell shell,
                                                       java.lang.String label,
                                                       DesignerProp parent,
                                                       GProp<?>[] props,
                                                       java.lang.String[] names,
                                                       boolean showErrorDialog)
        Creates the resources for the list of properties in the specified property.
        Parameters:
        shell - The shell.
        label - The label of the operation.
        parent - The parent property.
        props - The properties to create.
        names - The new (or existing) names of the properties.
        showErrorDialog - Flag to show an error dialog or not.
        Returns:
        null for OK, otherwise an error message.
      • createFile

        public static java.lang.String createFile​(org.eclipse.swt.widgets.Shell shell,
                                                  java.lang.String label,
                                                  org.eclipse.core.resources.IContainer folder,
                                                  PropCnr cnr,
                                                  java.lang.String fileName,
                                                  boolean doOverwrite)
        Creates a resource file for a property with undo support.
        Parameters:
        shell - The shell.
        label - Label for operation.
        folder - Folder to place file.
        cnr - The property container.
        fileName - The file name relative the folder.
        doOverwrite - Overwrite allowed flag.
        Returns:
        An error message, or null for success.
      • createFile

        public static java.lang.String createFile​(org.eclipse.swt.widgets.Shell shell,
                                                  java.lang.String label,
                                                  org.eclipse.core.resources.IContainer folder,
                                                  PropCnr cnr,
                                                  java.lang.String fileName,
                                                  boolean doOverwrite,
                                                  boolean showErrorDialog)
        Creates a resource file for a property with undo support.
        Parameters:
        shell - The shell.
        label - Label for operation.
        folder - Folder to place file.
        cnr - The property container.
        fileName - The file name relative the folder.
        doOverwrite - Overwrite allowed flag.
        showErrorDialog - Flag to show an error dialog or not.
        Returns:
        An error message, or null for success.