コード例 #1
0
  /**
   * Removes the passed profile from the configuration.
   *
   * @param p the profile to be removed
   */
  public void removeProfile(Profile p) {
    profiles.remove(p);
    try {
      profileModels.removeAll(p.getProfilePackages());
    } catch (ProfileException e) {
      LOG.error("Exception", e);
    }

    FigNodeStrategy fns = p.getFigureStrategy();
    if (fns != null) {
      figNodeStrategies.remove(fns);
    }

    if (formatingStrategy == p.getFormatingStrategy()) {
      formatingStrategy = null;
    }

    List<Profile> markForRemoval = new ArrayList<Profile>();
    for (Profile profile : profiles) {
      if (profile.getDependencies().contains(p)) {
        markForRemoval.add(profile);
      }
    }

    for (Profile profile : markForRemoval) {
      removeProfile(profile);
    }

    updateStrategies();
    ArgoEventPump.fireEvent(
        new ArgoProfileEvent(
            ArgoEventTypes.PROFILE_REMOVED, new PropertyChangeEvent(this, "profile", p, null)));
  }
コード例 #2
0
  /**
   * Applies a new profile to this configuration
   *
   * @param p the profile to be applied
   */
  @SuppressWarnings("unchecked")
  public void addProfile(Profile p) {
    if (!profiles.contains(p)) {
      profiles.add(p);
      try {
        profileModels.addAll(p.getProfilePackages());
      } catch (ProfileException e) {
        LOG.warn("Error retrieving profile's " + p + " packages.", e);
      }

      FigNodeStrategy fns = p.getFigureStrategy();
      if (fns != null) {
        figNodeStrategies.add(fns);
      }

      for (Profile dependency : p.getDependencies()) {
        addProfile(dependency);
      }

      updateStrategies();
      ArgoEventPump.fireEvent(
          new ArgoProfileEvent(
              ArgoEventTypes.PROFILE_ADDED, new PropertyChangeEvent(this, "profile", null, p)));
    }
  }
コード例 #3
0
 /**
  * Updates the current strategy to the strategy provided by the passed profile. The profile should
  * have been previously registered.
  *
  * @param profile the profile providing the current formating strategy
  */
 public void activateFormatingStrategy(Profile profile) {
   if (profile != null
       && profile.getFormatingStrategy() != null
       && getProfiles().contains(profile)) {
     this.formatingStrategy = profile.getFormatingStrategy();
   }
 }
コード例 #4
0
 /**
  * Updates the current strategy to the strategy provided by the passed profile. The profile should
  * have been previously registered.
  *
  * @param profile the profile providing the current default type strategy
  */
 public void activateDefaultTypeStrategy(Profile profile) {
   if (profile != null
       && profile.getDefaultTypeStrategy() != null
       && getProfiles().contains(profile)) {
     this.defaultTypeStrategy = profile.getDefaultTypeStrategy();
   }
 }
コード例 #5
0
 /*
  * @see org.argouml.profile.ProfileManager#lookForRegisteredProfile(java.lang.String)
  */
 public Profile lookForRegisteredProfile(String value) {
   if (value != null) {
     List<Profile> registeredProfiles = getRegisteredProfiles();
     for (Profile profile : registeredProfiles) {
       if (value.equalsIgnoreCase(profile.getProfileIdentifier())) {
         return profile;
       }
     }
   }
   return null;
 }
コード例 #6
0
 /** test profile manager */
 public void testProfileManagerImpl() {
   List<Profile> registeredProfiles = manager.getRegisteredProfiles();
   assertTrue(1 <= registeredProfiles.size());
   Set<String> internalProfileNameSet = new HashSet<String>();
   for (Profile profile : registeredProfiles) {
     if (profile.getDisplayName().equals(ProfileUML.NAME_UML14)) {
       internalProfileNameSet.add(profile.getDisplayName());
     }
   }
   assertEquals(1, internalProfileNameSet.size());
 }
コード例 #7
0
 /*
  * @param pc
  * @see org.argouml.profile.ProfileManager#applyConfiguration(org.argouml.kernel.ProfileConfiguration)
  */
 public void applyConfiguration(ProfileConfiguration pc) {
   for (Profile p : this.profiles) {
     for (Critic c : p.getCritics()) {
       c.setEnabled(false);
       Configuration.setBoolean(c.getCriticKey(), false);
     }
   }
   for (Profile p : pc.getProfiles()) {
     for (Critic c : p.getCritics()) {
       c.setEnabled(true);
       Configuration.setBoolean(c.getCriticKey(), true);
     }
   }
 }
コード例 #8
0
 private void updateDefaultProfilesConfiguration() {
   if (!disableConfigurationUpdate) {
     StringBuffer buf = new StringBuffer();
     for (Profile p : defaultProfiles) {
       if (p instanceof UserDefinedProfile) {
         buf.append("U" + ((UserDefinedProfile) p).getModelFile().toURI().toASCIIString());
       } else {
         buf.append("C" + p.getProfileIdentifier());
       }
       buf.append(DIRECTORY_SEPARATOR);
     }
     Configuration.setString(KEY_DEFAULT_PROFILES, buf.toString());
   }
 }
コード例 #9
0
  public Profile getProfileForClass(String profileClass) {
    Profile found = null;

    // If we found an old-style name, update it to the new package name
    if (profileClass != null && profileClass.startsWith(OLD_PROFILE_PACKAGE)) {
      profileClass = profileClass.replace(OLD_PROFILE_PACKAGE, NEW_PROFILE_PACKAGE);
    }

    // Make sure the names didn't change again
    assert profileUML.getClass().getName().startsWith(NEW_PROFILE_PACKAGE);

    for (Profile p : profiles) {
      if (p.getClass().getName().equals(profileClass)) {
        found = p;
        break;
      }
    }
    return found;
  }
コード例 #10
0
  /**
   * @param p the profile to register.
   * @return true if there should be an attempt to load the default profiles from the configuration.
   */
  private boolean registerProfileInternal(Profile p) {

    try {
      boolean loadDefaultProfilesFromConfiguration = false;
      if (p != null && !profiles.contains(p)) {
        if (p instanceof UserDefinedProfile || getProfileForClass(p.getClass().getName()) == null) {
          loadDefaultProfilesFromConfiguration = true;
          profiles.add(p);
          for (Critic critic : p.getCritics()) {
            for (Object meta : critic.getCriticizedDesignMaterials()) {
              Agency.register(critic, meta);
            }
            critic.setEnabled(false);
          }
        }
      }
      return loadDefaultProfilesFromConfiguration;
    } catch (RuntimeException e) {
      // TODO: Better if we wrap in a ProfileException and throw that
      LOG.error("Error registering profile " + p.getDisplayName());
      throw e;
    }
  }
コード例 #11
0
 public void removeProfile(Profile p) {
   if (p != null && p != profileUML) {
     profiles.remove(p);
     defaultProfiles.remove(p);
   }
   try {
     Collection packages = p.getLoadedPackages();
     if (packages != null && !packages.isEmpty()) {
       // We assume profile is contained in a single extent
       Model.getUmlFactory().deleteExtent(packages.iterator().next());
     }
   } catch (ProfileException e) {
     // Nothing to delete if we couldn't get the packages
   }
 }