Package org.jamesii.core.model.plugintype

Examples of org.jamesii.core.model.plugintype.ModelFactory


  }

  @Override
  public void valueChanged(ListSelectionEvent e) {
    try {
      final ModelFactory value = (ModelFactory) list.getSelectedValue();
      canNext = value != null;

      final StringBuilder editors = new StringBuilder();

      model = modelCache.get(value);
      // try to determine available editors
      if (value != null) {
        if (model == null) {
          model = value.create();
          modelCache.put(value, model);
        }

        canNext = canNext && model != null;

        modelWindowFactories = modelWindowFactoryCache.get(model);

        if (modelWindowFactories == null) {
          // get editors available for formalism (if none also disable
          // next
          // button)
          ParameterBlock amwfp =
              new ParameterBlock(model, AbstractModelWindowFactory.MODEL);

          modelWindowFactories =
              SimSystem.getRegistry().getFactoryOrEmptyList(
                  AbstractModelWindowFactory.class, amwfp);

          modelWindowFactoryCache.put(model, modelWindowFactories);
        }

        if (modelWindowFactories.size() == 0) {
          // no editors
          canNext = false;
          editors
              .append("<blockquote><b><font color=\"#CC0000\">None</font></b></blockquote><br />This must not be due to an error.<br/>You can still (at least) use Java to create your model!");
        } else {
          editors.append("<ul>");
          for (ModelWindowFactory f : modelWindowFactories) {
            IFactoryInfo info =
                SimSystem.getRegistry().getFactoryInfo(f.getClass().getName());
            editors.append(String.format(
                "<li>%s %s</li>",
                f.getReadableName(),
                info.getDescription() != null
                    && info.getDescription().length() > 0 ? "("
                    + info.getDescription() + ")" : ""));
          }
          editors.append("</ul>");
        }
      }
      // show editor info

      // also update information about selected model factory
      BasicUtilities.invokeLaterOnEDT(new Runnable() {

        @Override
        public void run() {
          if (value != null) {
            String info =
                String
                    .format(
                        "<html><h1>%s (%s)</h1><h2>Comment</h2>%s<h2>Available Editors</h2>%s</html>",
                        value.getFormalism().getName(), value.getFormalism()
                            .getAcronym(), value.getFormalism().getComment(),
                        editors.toString());
            infoLabel.setContentType("text/html");
            infoLabel.setText(info);
            infoLabel.setCaretPosition(0);
          } else {
View Full Code Here

TOP

Related Classes of org.jamesii.core.model.plugintype.ModelFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.