Class DefinitionFilesRefactoring

java.lang.Object
com.iizigo.project.DefinitionFilesRefactoring

public final class DefinitionFilesRefactoring extends Object
The refactoring participant for the project-definition files of a Module project: the files in the project's root that define the application and name its VirtualSpace, text table, images, icons and classes by reference. When a property is renamed or moved - a file, a folder or a property inside a file, by the Rename dialog, a drag in the IIZI Explorer, a Java refactoring, or the undo of any of them - the references these files hold must follow, whether or not the file's page was ever opened. Two cases:
  • .iiziModuleProject, the Module settings. The Designer keeps them in the project's model, so their references follow in memory by themselves. Nothing is done for them here: the settings file is a member of the unsaved set like every file of the Module's folders (ModuleModel.settingsOnDisk, com.iizigo.prop.UnsavedFiles). A change of the settings that followed a refactoring is not saved until Save All, or the question of a close, a rename, a delete or the exit, saves it with the files that followed the same refactoring; it is never written at the refactoring itself (CC-FIX-TREE-RENAME-UNSAVED; from r22404 until then this class wrote the file at once).
  • .iiziRun (the iiziRun Builder), .iiziPWA, .iiziPush and .iiziApp. Each is loaded only while its page is open, so a reference one of them holds - the text table of .iiziRun, the icons of .iiziPWA - is in no property tree when the property it names is renamed, and nothing made it follow. Here the rename or move event of a module's tree is turned into the old and the new reference, and the references of those files follow in every loaded Module project. A file is read as text first and loaded only when it holds the old name; it is written only when a reference in it changed, as its page writes it. The undo of the rename arrives as another rename and writes the old name back.
The files are written by a job: a rename of a file or folder is heard while the workspace is locked for changes.

Hooked from ModuleRootPropCnr.onEventSelf, which every event of a module's tree reaches.

Author:
Christopher Mindus
  • Field Details

  • Method Details

    • onEvent

      public static void onEvent(ModuleRootPropCnr root, GEvent event)
      Called for every event a module root hears: acts on a rename or move of a property, ignores everything else. A changed value of the Module settings is nothing to do here: the settings file is changed and not saved then, like the files that followed the same refactoring.
      Parameters:
      root - The module root.
      event - The event.
    • follow

      public static int follow(PropCnr file, PropCnr root, String project, List<String[]> renames) throws PropException
      Has the references of a loaded definition file follow renames and moves.
      Parameters:
      file - The root of the loaded file, not in any tree.
      root - The root of the Module project the file belongs to: it knows the project's aliases.
      project - The name of that Module project.
      renames - The old and the new reference of each rename or move, in their order.
      Returns:
      The count of the references that changed.
      Throws:
      PropException - If a reference refuses its new name.
    • follow

      public static String follow(String ref, String oldRef, String newRef, PropCnr root, String project)
      Has one reference follow one rename or move. The reference keeps its form: with the name of its module ("module:/path"), with an alias of it ("*alias:/path"), or without a module for a property of its own module ("/path").
      Parameters:
      ref - The reference as the file holds it.
      oldRef - The old reference of the renamed or moved property, "module:/path".
      newRef - Its new reference.
      root - The root of the Module project the file belongs to.
      project - The name of that Module project.
      Returns:
      The reference as the file holds it from now on: ref itself when it names neither the property nor a property below it.