Exemple #1
0
 /**
  * This private method takes the Postprocessor tree node and populates the postProcessorData
  * DataComponent.
  *
  * @param ppTree
  */
 private void setupPostprocessorData(TreeComposite ppTree) {
   postProcessorsData.clearEntries();
   for (int i = 0; i < ppTree.getNumberOfChildren(); i++) {
     Entry ppEntry =
         new Entry() {
           @Override
           public void setup() {
             allowedValueType = AllowedValueType.Discrete;
             allowedValues.add("yes");
             allowedValues.add("no");
             defaultValue = "no";
           }
         };
     ppEntry.setName(ppTree.getChildAtIndex(i).getName());
     ppEntry.setDescription("Select whether this Postprocessor should be displayed in real-time.");
     ppEntry.setId(i);
     postProcessorsData.addEntry(ppEntry);
   }
 }
  /**
   * Adds a new <code>Entry</code> (aka property or parameter) to the active or first available data
   * node in the {@link #tree}.
   */
  private void addParameter() {

    // Get either the active data node or the first available data node.
    DataComponent dataNode = canAdd(tree);

    // If there is a data node, add a new Entry to it.
    if (dataNode != null && !dataNode.contains("New parameter")) {
      // Create an Entry with a BasicEntryContentProvider.
      Entry entry = new Entry(new BasicEntryContentProvider());
      // Set the Entry's initial properties.
      entry.setName("new_parameter");
      entry.setDescription("");
      entry.setTag(entry.getName());
      entry.setRequired(false);
      entry.setValue("");
      // Add the Entry to the data node.
      dataNode.addEntry(entry);
    }

    return;
  }
Exemple #3
0
  /**
   * This method searches the Model input tree and locates all file Entries and loads them on the
   * Model File DataComponent.
   */
  protected void loadFileEntries() {
    // Walk the tree and get all Entries that may represent a file
    BreadthFirstTreeCompositeIterator iter = new BreadthFirstTreeCompositeIterator(modelTree);
    while (iter.hasNext()) {
      TreeComposite child = iter.next();

      // Make sure we have a valid DataComponent
      if (child.getActiveDataNode() != null && child.isActive()) {
        DataComponent data = (DataComponent) child.getActiveDataNode();
        for (Entry e : data.retrieveAllEntries()) {

          // If the Entry's tag is "false" it is a commented out
          // parameter.
          if (!"false".equals(e.getTag())
              && e.getValue() != null
              && !e.getValue().isEmpty()
              && (e.getName() + " = " + e.getValue())
                  .matches(mooseLauncher.getFileDependenciesSearchString())) {

            Entry clonedEntry = (Entry) e.clone();

            // If this Entry does not have a very descriptive
            // name
            // we should reset its name to the block it belongs
            // to
            if ("file".equals(clonedEntry.getName().toLowerCase())
                || "data_file".equals(clonedEntry.getName().toLowerCase())) {
              clonedEntry.setName(child.getName());
            }

            if (!clonedEntry.getValueType().equals(AllowedValueType.File)) {
              mooseModel.convertToFileEntry(clonedEntry);
            }

            // Setup allowed values correctly
            String extension =
                FilenameUtils.getExtension(
                    project.getFile(clonedEntry.getValue()).getLocation().toOSString());

            // Create a new content provider with the new file
            // in the allowed values list
            IEntryContentProvider prov = new BasicEntryContentProvider();
            ArrayList<String> valueList = clonedEntry.getAllowedValues();

            for (String file : getProjectFileNames(extension)) {
              if (!valueList.contains(file)) {
                valueList.add(file);
              }
            }
            prov.setAllowedValueType(AllowedValueType.File);

            // Finish setting the allowed values and default
            // value
            prov.setAllowedValues(valueList);

            // Set the new provider
            clonedEntry.setContentProvider(prov);

            // Set the value
            clonedEntry.setValue(e.getValue());

            fileEntryTreeMapping.put(clonedEntry.getName(), child);

            clonedEntry.register(this);

            // Add it to the list of model files.
            modelFiles.addEntry(clonedEntry);
          }
        }
      }
    }

    return;
  }