/**
   * 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)));
  }
  /**
   * 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)));
    }
  }
 /**
  * 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();
   }
 }
 /**
  * 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;
 }
 /** 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
   }
 }