/**
  * Load an icon for a supported project file.
  *
  * @param f the file to check
  * @return a nice icon if the file is known as a project file, otherwise a default one
  */
 public Icon getIcon(File f) {
   AbstractFilePersister persister =
       PersistenceManager.getInstance().getPersisterFromFileName(f.getName());
   if (persister != null && persister.hasAnIcon()) {
     return Argo.lookupIconResource("UmlNotation");
   } else {
     return null;
   }
 }
Example #2
0
  /**
   * Test remove() function. This is called when a new project is created to remove the old project.
   * We confirm here that the users model has been emptied and that no none 'Model' model elements
   * are at root.
   *
   * @throws InterruptedException if there the project load was interrupted
   * @throws OpenException if there was an error during project load
   * @throws URISyntaxException when the URI can not be formed
   */
  public void testRemove() throws OpenException, InterruptedException, URISyntaxException {
    String name = "/testmodels/uml14/Alittlebitofeverything.zargo";
    URL url = TestProject.class.getResource(name);
    AbstractFilePersister persister =
        PersistenceManager.getInstance().getPersisterFromFileName(name);

    URI uri = url.toURI();
    Project p = persister.doLoad(new File(uri));

    p.remove();

    for (Object root : Model.getFacade().getRootElements()) {
      assertTrue(
          "All roots should be a Model - but found a " + Model.getMetaTypes().getName(root),
          Model.getFacade().isAModel(root));
      System.out.println(
          Model.getFacade().getName(root) + " " + Model.getFacade().getOwnedElements(root).size());
      if ("untitledModel".equals(Model.getFacade().getName(root))) {
        assertEquals(
            "All root models should be empty", 0, Model.getFacade().getOwnedElements(root).size());
      }
    }
  }