Example #1
0
  /**
   * Topological sorts the graph using and returns the order as list. It tries to bring Objects on
   * one common level in a sorted order. If a loop is detected, it returns null as no sorting is
   * possible.
   *
   * @return DOCUMENT ME!
   * @throws IllegalStateException DOCUMENT ME!
   */
  public final Set<T> orderedTopologicalSort() {
    final Set<T> result = TypeSafeCollections.newLinkedHashSet();
    final Map<T, Set<T>> orderedAdjacencyListCopy = TypeSafeCollections.newLinkedHashMap();
    final List<T> pathsToOrderList = TypeSafeCollections.newArrayList(adjacencyList.keySet());
    if (comparator != null) {
      Collections.sort(pathsToOrderList, comparator);
    }
    for (final T item : pathsToOrderList) {
      orderedAdjacencyListCopy.put(item, new HashSet<T>(adjacencyList.get(item)));
    }
    while (!orderedAdjacencyListCopy.isEmpty()) {
      final List<T> current = TypeSafeCollections.newArrayList();
      final Iterator<Entry<T, Set<T>>> it = orderedAdjacencyListCopy.entrySet().iterator();
      T item = null;
      while (it.hasNext()) {
        final Entry<T, Set<T>> entry = it.next();
        item = entry.getKey();
        final Set<T> chk = entry.getValue();
        if ((chk == null) || chk.isEmpty()) {
          it.remove();
          current.add(item);
          for (final Set<T> set : orderedAdjacencyListCopy.values()) {
            set.remove(item);
          }
        }
      }
      if (current.isEmpty()) {
        throw new IllegalStateException(
            "Relationgraph has cyclic dependencies on item " + item + "!");
      }

      result.addAll(current);
    }
    return result;
  }
Example #2
0
 /**
  * Creates a new ProjectOptions object.
  *
  * @param addClassPath DOCUMENT ME!
  * @param driver DOCUMENT ME!
  * @param defFinClass DOCUMENT ME!
  * @param defFinProps DOCUMENT ME!
  */
 public ProjectOptions(
     final Set<File> addClassPath,
     final List<DriverDescription> driver,
     final String defFinClass,
     final Properties defFinProps) {
   if (addClassPath != null) {
     this.addClassPath = addClassPath;
   } else {
     this.addClassPath = TypeSafeCollections.newHashSet();
   }
   if (driver != null) {
     this.driver = driver;
   } else {
     this.driver = TypeSafeCollections.newArrayList();
   }
   if (defFinClass != null) {
     this.defaultFinalizerClass = defFinClass;
   } else {
     this.defaultFinalizerClass = "";
   }
   if (defFinProps != null) {
     this.defaultFinalizerProperties = defFinProps;
   } else {
     this.defaultFinalizerProperties = new Properties();
   }
 }
Example #3
0
 /**
  * DOCUMENT ME!
  *
  * @param driver DOCUMENT ME!
  */
 public void setDriver(final List<DriverDescription> driver) {
   if (driver != null) {
     this.driver = driver;
   } else {
     this.driver = TypeSafeCollections.newArrayList();
   }
 }
Example #4
0
 /**
  * DOCUMENT ME!
  *
  * @param mappings DOCUMENT ME!
  */
 public void setContent(List<Mapping> mappings) {
   if (mappings == null) {
     mappings = TypeSafeCollections.newArrayList();
   }
   // this.mappings = mappings;
   // TableSorter ts = new TableSorter(new MappingModel(mappings));
   // tblMappings.setModel(ts);
   if (tblMappings.getModel() != null) {
     tblMappings.getModel().removeTableModelListener(topComponent);
   }
   tblMappings.setModel(new MappingModel(mappings));
   tblMappings.getModel().addTableModelListener(topComponent);
 }
Example #5
0
  /**
   * DOCUMENT ME!
   *
   * @param fieldNames DOCUMENT ME!
   */
  public void prepareAutoComplete(final String[] fieldNames) {
    final List<String> tmp = TypeSafeCollections.newArrayList();
    if (codeProvider != null) {
      tmp.addAll(codeProvider.getFunctionList());
    }
    if (fieldNames != null) {
      this.fldNames = fieldNames.clone();
    }
    if (this.fldNames != null) {
      for (final String s : this.fldNames) {
        tmp.add(s);
      }
    }
    final TableColumn tc = tblMappings.getColumnModel().getColumn(1);
    Collections.sort(tmp);

    final SmartComboBox combo = new SmartComboBox(tmp.toArray(new String[] {}));
    combo.setBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0));
    combo.setEditable(true);
    combo.setCaseSensitive(true);
    final MultiClickComboBoxCellEditor ed = new MultiClickComboBoxCellEditor(combo);
    tc.setCellEditor(ed);
    ed.addCellEditorListener(combo);
  }
Example #6
0
 /** <editor-fold defaultstate="collapsed" desc="Constructors">. */
 public ProjectOptions() {
   this.addClassPath = TypeSafeCollections.newHashSet();
   this.driver = TypeSafeCollections.newArrayList();
   this.defaultFinalizerClass = "";
   this.defaultFinalizerProperties = new Properties();
 }
Example #7
0
 /**
  * DOCUMENT ME!
  *
  * @return DOCUMENT ME!
  */
 public final Set<T> reverseOrderedTopologicalSort() {
   final List<T> tmp = TypeSafeCollections.newArrayList(orderedTopologicalSort());
   Collections.reverse(tmp);
   final Set<T> res = TypeSafeCollections.newLinkedHashSet(tmp);
   return res;
 }