public static GraphicalEditorInput createInstance(Object c_input) throws PartInitException {
   ModelSpecification_c[] modelSpecs =
       ModelSpecification_c.ModelSpecificationInstances(Ooaofgraphics.getDefaultInstance());
   for (int i = 0; i < modelSpecs.length; i++) {
     if (modelSpecs[i].getRepresents() == c_input.getClass()) {
       final UUID ooa_id = Cl_c.Getooa_idfrominstance(c_input);
       final int modelType = modelSpecs[i].getModel_type();
       String rootName = Cl_c.getModelRootname(c_input);
       if (rootName != null) {
         Ooaofgraphics modelRoot = Ooaofgraphics.getInstance(rootName);
         Model_c canvas =
             Model_c.ModelInstance(
                 modelRoot,
                 new ClassQueryInterface_c() {
                   public boolean evaluate(Object candidate) {
                     Model_c selected = (Model_c) candidate;
                     return selected.getModel_type() == modelType
                         && selected.getOoa_id().equals(ooa_id);
                   }
                 });
         if (canvas != null) {
           CanvasModelListener.setGraphicalRepresents(canvas);
           return new GraphicalEditorInput(canvas, c_input, modelSpecs[i].getBackground());
         }
       }
     }
   }
   return null;
 }
示例#2
0
  /*
   * Get the "-" separated list of names of the parent elements.
   */
  public static String getContainerList(Model_c model, Ooaofooa modelRoot) {
    int ooaType = model.getOoa_type();
    NonRootModelElement elem =
        (NonRootModelElement) Cl_c.Getinstancefromooa_id(modelRoot, model.getOoa_id(), ooaType);

    return getContainerList(elem, ooaType);
  }
 private void createElement(String creationMethod, Object container) {
   // new a test Model Class
   Transaction transaction = null;
   try {
     transaction =
         TransactionManager.getSingleton()
             .startTransaction(
                 "Create test element.",
                 new ModelElement[] {
                   Ooaofooa.getDefaultInstance(), Ooaofgraphics.getDefaultInstance()
                 });
     Method method = Cl_c.findMethod(container, creationMethod, new Class<?>[0]);
     Cl_c.doMethod(method, container, new Object[0]);
     TransactionManager.getSingleton().endTransaction(transaction);
   } catch (TransactionException e) {
     if (transaction != null) {
       TransactionManager.getSingleton().cancelTransaction(transaction, e);
     }
   }
   // allow reconciler to kick in
   BaseTest.dispatchEvents(0);
 }
  /* (non-Javadoc)
   * @see org.eclipse.ui.IPersistableElement#saveState(org.eclipse.ui.IMemento)
   */
  public void saveState(IMemento memento) {
    String root_id = m_input.getModelRoot().getId();
    Ooaofooa modelRoot = Ooaofooa.getInstance(root_id, false);

    memento.putString(GraphicalEditorFactory.TAG_MODELROOTID, m_input.getModelRoot().getId());
    memento.putString(GraphicalEditorFactory.TAG_OOAID, m_input.getOoa_id().toString());
    memento.putInteger(GraphicalEditorFactory.TAG_OOATYPE, m_input.getOoa_type());
    memento.putInteger(GraphicalEditorFactory.TAG_MODELTYPE, m_input.getModel_type());
    NonRootModelElement nrme = (NonRootModelElement) m_input.getRepresents();
    if (nrme == null) {
      nrme =
          (NonRootModelElement)
              Cl_c.Getinstancefromooa_id(modelRoot, m_input.getOoa_id(), m_input.getOoa_type());
    }

    // if there's no way to get a component path, then don't save the tag
    // CanvasFactory.createElement() will check for the tag's existence
    // before doing anything
    if (nrme != null) {
      memento.putString(GraphicalEditorFactory.TAG_COMPONENTPATH, nrme.getContent());
    }
  }