Пример #1
0
 private static void assertEqualList(List<?> a, Collection<?> b) {
   if (a.size() == b.size()) {
     for (Object x : a) {
       if (!b.contains(x))
         throw new AssertionFailedError("expected:<" + a + "> but was: <" + b + ">");
     }
     return;
   }
   throw new AssertionFailedError("expected:<" + a + "> but was: <" + b + ">");
 }
Пример #2
0
 private void writeState(XMLWriter writer) {
   writer.startTag(RepositoriesViewContentHandler.REPOSITORIES_VIEW_TAG, null, true);
   // Write the repositories
   Collection repos = Arrays.asList(getKnownRepositoryLocations());
   Iterator it = repos.iterator();
   while (it.hasNext()) {
     CVSRepositoryLocation location = (CVSRepositoryLocation) it.next();
     RepositoryRoot root = getRepositoryRootFor(location);
     root.writeState(writer);
   }
   writer.endTag(RepositoriesViewContentHandler.REPOSITORIES_VIEW_TAG);
 }
Пример #3
0
 /**
  * Run the given runnable, waiting until the end to perform a refresh
  *
  * @param runnable
  * @param monitor
  */
 public void run(IRunnableWithProgress runnable, IProgressMonitor monitor)
     throws InvocationTargetException, InterruptedException {
   try {
     notificationLevel++;
     runnable.run(monitor);
   } finally {
     notificationLevel = Math.max(0, notificationLevel - 1);
     if (notificationLevel == 0) {
       try {
         Collection roots = changedRepositories.values();
         broadcastRepositoriesChanged(
             (ICVSRepositoryLocation[]) roots.toArray(new ICVSRepositoryLocation[roots.size()]));
       } finally {
         changedRepositories.clear();
       }
     }
   }
 }
Пример #4
0
  public void addPackageClass(PackageClass pClass) {

    Document doc;
    try {
      doc = getDocument();
    } catch (Exception e) {
      e.printStackTrace();
      return;
    }

    String name = pClass.getName();

    // check if such class exists and remove duplicates
    Element rootEl = doc.getDocumentElement();
    NodeList classEls = rootEl.getElementsByTagName(EL_CLASS);
    for (int i = 0; i < classEls.getLength(); i++) {
      Element nameEl = getElementByName((Element) classEls.item(i), EL_NAME);
      if (name.equals(nameEl.getTextContent())) {
        rootEl.removeChild(classEls.item(i));
      }
    }

    Element classNode = doc.createElement(EL_CLASS);
    doc.getDocumentElement().appendChild(classNode);
    classNode.setAttribute(ATR_TYPE, PackageClass.ComponentType.SCHEME.getXmlName());
    classNode.setAttribute(ATR_STATIC, "false");

    Element className = doc.createElement(EL_NAME);
    className.setTextContent(name);
    classNode.appendChild(className);

    Element desrc = doc.createElement(EL_DESCRIPTION);
    desrc.setTextContent(pClass.getDescription());
    classNode.appendChild(desrc);

    Element icon = doc.createElement(EL_ICON);
    icon.setTextContent(pClass.getIcon());
    classNode.appendChild(icon);

    // graphics
    classNode.appendChild(generateGraphicsNode(doc, pClass.getGraphics()));

    // ports
    List<Port> ports = pClass.getPorts();
    if (!ports.isEmpty()) {
      Element portsEl = doc.createElement(EL_PORTS);
      classNode.appendChild(portsEl);

      for (Port port : ports) {
        portsEl.appendChild(generatePortNode(doc, port));
      }
    }

    // fields
    Collection<ClassField> fields = pClass.getFields();
    if (!fields.isEmpty()) {
      Element fieldsEl = doc.createElement(EL_FIELDS);
      classNode.appendChild(fieldsEl);

      for (ClassField cf : fields) {
        fieldsEl.appendChild(generateFieldNode(doc, cf));
      }
    }

    // write
    try {
      writeDocument(doc, new FileOutputStream(xmlFile));
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
  }