Ejemplo n.º 1
0
 private List<Set> findContentNodes(final Map<UUID, Set> instanceMap, final UUID containerUUID) {
   final List<Set> contentNodes = new ArrayList<Set>();
   for (final Entry<UUID, Set> entry : instanceMap.entrySet()) {
     final Set i = entry.getValue();
     if (i.container() != null
         && i.container().identity().uniqueRepresentationReference().equals(containerUUID)) {
       contentNodes.add(i);
     }
   }
   return contentNodes;
 }
Ejemplo n.º 2
0
 private void buildChangesetNode(
     final Map<UUID, Set> instanceMap, final ChangesetNode node, final Map<UUID, Set> skipMap) {
   final Set instance = node.getSet();
   skipMap.put(instance.identity().uniqueRepresentationReference(), instance);
   final List<Set> containedInstances =
       findContentNodes(instanceMap, instance.identity().uniqueRepresentationReference());
   for (final Set i : containedInstances) {
     final ChangesetNode childNode = new ChangesetNode(node, i);
     node.addChildNode(childNode);
     buildChangesetNode(instanceMap, childNode, skipMap);
   }
 }
Ejemplo n.º 3
0
  private Set findIcon(final Set graphVisualization) {
    final Set container = set.container();

    for (final Set symbol_to_si :
        graphVisualization.filter(Visualization.symbol_to_semantic_identity)) {
      if (symbol_to_si.to().isEqualTo(set)
          && symbol_to_si.fromEdgeEnd().isEqualTo(CellPlatformDomain.theDefault)) {
        return symbol_to_si.from();
      }
    }
    // create the icon artefact, as it does not exist yet
    final Set icon = graphVisualization.addConcrete(Visualization.symbol, CellPlatformDomain.icon);
    Instantiation.arrow(
        Visualization.symbol_to_semantic_identity,
        S23MSemanticDomains.anonymous,
        CellPlatformDomain.theDefault,
        icon,
        S23MSemanticDomains.minCardinality_NOTAPPLICABLE,
        S23MSemanticDomains.maxCardinality_NOTAPPLICABLE,
        S23MSemanticDomains.isNavigable_NOTAPPLICABLE,
        S23MSemanticDomains.isContainer_FALSE,
        set,
        set,
        S23MSemanticDomains.minCardinality_NOTAPPLICABLE,
        S23MSemanticDomains.maxCardinality_NOTAPPLICABLE,
        S23MSemanticDomains.isNavigable_NOTAPPLICABLE,
        S23MSemanticDomains.isContainer_FALSE);
    return createGraphVisualization(container);
  }
Ejemplo n.º 4
0
 private void serializeNodePath(
     final Serializer serializer,
     final ChangesetNode node,
     final List<String> serializedInstances) {
   final Set set = node.getSet();
   if (set.properClass().isEqualTo(S23MKernel.coreGraphs.vertex)) {
     final String content = serializer.serializeInstance(set, false).getContent();
     serializedInstances.add(content);
     final UUID uuid = node.getSet().identity().uniqueRepresentationReference();
     objectPool.addArtifact(
         uuid.toString(),
         new ObjectPoolArtifact(
             uuid,
             S23MKernel.coreGraphs.graph.identity().uniqueRepresentationReference(),
             content));
     for (final ChangesetNode childNode : node.getChildNodes()) {
       serializeNodePath(serializer, childNode, serializedInstances);
     }
   }
 }
Ejemplo n.º 5
0
  // Copied from TestSequence
  private Set createGraphVisualization(final Set graph) {
    final Set gv =
        RepositoryStructure.graphVisualizations.addConcrete(
            Visualization.graphVisualization, graph);
    final Set v = gv.addConcrete(Visualization.visualizedGraph, graph);

    final Set vg_to_graph =
        Instantiation.arrow(
            Visualization.visualizedGraph_to_graph,
            S23MSemanticDomains.anonymous,
            Visualization.visualizedGraph,
            v,
            S23MSemanticDomains.minCardinality_NOTAPPLICABLE,
            S23MSemanticDomains.maxCardinality_NOTAPPLICABLE,
            S23MSemanticDomains.isNavigable_NOTAPPLICABLE,
            S23MSemanticDomains.isContainer_FALSE,
            graph,
            graph,
            S23MSemanticDomains.minCardinality_NOTAPPLICABLE,
            S23MSemanticDomains.maxCardinality_NOTAPPLICABLE,
            S23MSemanticDomains.isNavigable_NOTAPPLICABLE,
            S23MSemanticDomains.isContainer_FALSE);

    final Set details = gv.addConcrete(Visualization.details, Visualization.details);
    final Set structure = gv.addConcrete(Visualization.structure, Visualization.structure);
    final Set reuse = gv.addConcrete(Visualization.reuse, Visualization.reuse);
    final Set visibilities = gv.addConcrete(Visualization.visibilities, Visualization.visibilities);
    return gv;
  }
Ejemplo n.º 6
0
 private Set findGraphVisualization() {
   final Set container = set.container();
   for (final Set gv : RepositoryStructure.graphVisualizations.filterInstances()) {
     for (final Set vis_to_visGraph : gv.filter(Visualization.visualizedGraph_to_graph)) {
       if (vis_to_visGraph.to().isEqualTo(container)) {
         return vis_to_visGraph.from().container();
       }
     }
   }
   // create the visualisation artefact, as it does not exist yet
   return createGraphVisualization(container);
 }
Ejemplo n.º 7
0
 private void persistChangeset() {
   final Set changeSet = org.s23m.cell.api.Query.changedSets();
   if (changeSet != null && changeSet.size() > 0) {
     final Map<UUID, Set> instanceMap = new HashMap<UUID, Set>();
     final Map<UUID, Set> containerMap = new HashMap<UUID, Set>();
     final Map<UUID, Set> skipMap = new HashMap<UUID, Set>();
     final List<ChangesetNode> nodePaths = new ArrayList<ChangesetNode>();
     final Iterator<Set> setItr = changeSet.iterator();
     while (setItr.hasNext()) {
       final Set changeSetInstance = setItr.next();
       instanceMap.put(
           changeSetInstance.identity().uniqueRepresentationReference(), changeSetInstance);
       if (changeSetInstance.container() != null) {
         containerMap.put(
             changeSetInstance.container().identity().uniqueRepresentationReference(),
             changeSetInstance);
       }
     }
     for (final Entry<UUID, Set> entry : instanceMap.entrySet()) {
       if (!skipMap.containsKey(entry.getKey())) {
         final Set changesetInstance = entry.getValue();
         if (containerMap.containsKey(
             changesetInstance.identity().uniqueRepresentationReference())) {
           // Check for cases where changesetInstance is a middle node
           if (changesetInstance.container() != null
               && !instanceMap.containsKey(
                   changesetInstance.container().identity().uniqueRepresentationReference())) {
             final ChangesetNode node = new ChangesetNode(null, changesetInstance);
             buildChangesetNode(instanceMap, node, skipMap);
             nodePaths.add(node);
           }
         } else {
           // Got its container in the map? if not put it the path list
           if (changesetInstance.container() != null
               && !instanceMap.containsKey(
                   changesetInstance.container().identity().uniqueRepresentationReference())) {
             nodePaths.add(new ChangesetNode(null, changesetInstance));
           }
         }
       }
     }
     // Serialize nodepaths and flick them to the repository
     final Serializer serializer =
         SerializerHolder.getS23MInstanceSerializer(SerializationType.XML);
     final List<String> serializedInstances = new ArrayList<String>();
     for (final ChangesetNode node : nodePaths) {
       serializeNodePath(serializer, node, serializedInstances);
     }
     persistArtifacts(serializedInstances);
   }
   // persistObjectPool();
 }
  private void createInputForm() {
    setCaption(action.getCaption());
    setWidth(WINDOW_WIDTH);

    setMargin(true);
    setSpacing(true);

    final Form inputForm = new Form();
    inputForm.setWidth(INPUT_FORM_WIDTH);
    addComponent(inputForm);
    inputForm.setImmediate(true);
    inputForm.setWriteThrough(false);

    final InstantiationData instData =
        new InstantiationData(metaInstance, containerInstance.identity().name(), false, "", "");
    final BeanItem<InstantiationData> instItem = new BeanItem<InstantiationData>(instData);
    inputForm.setItemDataSource(instItem);
    inputForm.setVisibleItemProperties(InstantiationData.getDisplayOrder());

    // drop handler
    final DragAndDropWrapper targetWrapper = new DragAndDropWrapper(inputForm);
    targetWrapper.setWidth(WINDOW_WIDTH);
    targetWrapper.setHeight("100%");

    targetWrapper.setDropHandler(
        new DropHandler() {

          public void drop(final DragAndDropEvent event) {
            final DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
            final TreeNode node = (TreeNode) t.getData("itemId");
            if (SetType.isSemanticDomainNode(node.getSet())) {
              instData.setIdentity(node.getSet());
              inputForm.getField(InstantiationData.NAME).requestRepaint();
              inputForm.getField(InstantiationData.PLURAL_NAME).requestRepaint();
              inputForm.setComponentError(null);
            } else {
              inputForm
                  .getItemDataSource()
                  .getItemProperty(InstantiationData.METAINSTANCE)
                  .setValue(node.getSet());
              inputForm.getField(InstantiationData.METAINSTANCE_NAME).requestRepaint();
            }
          }

          public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
          }
        });
    addComponent(targetWrapper);

    final HorizontalLayout okbar = new HorizontalLayout();
    okbar.setSpacing(true);
    okbar.setHeight(BUTTON_BAR_HEIGHT);
    inputForm.getFooter().addComponent(okbar);
    for (final String key : InstantiationData.getDisplayOrder()) {
      inputForm.getField(key).setWidth(FIELD_WIDTH);
    }

    final Button okBtn =
        new Button(
            OK_BUTTON_TEXT,
            new Button.ClickListener() {
              public void buttonClick(final ClickEvent event) {
                // create a new instance
                inputForm.commit();
                if (!checkForEmptyInstances(instData)) {
                  Set s = null;
                  String msgCaption = "";

                  if (action.equals(TreeActionHandler.ACTION_ADD)) {
                    msgCaption = INSTANCE_ADDITION_MSG;
                    if (instData.isAbstract()) {;
                      s =
                          containerInstance.addAbstract(
                              instData.getMetaInstance(), instData.getIdentity());
                    } else {
                      s =
                          containerInstance.addConcrete(
                              instData.getMetaInstance(), instData.getIdentity());
                    }
                  } else if (action.equals(TreeActionHandler.ACTION_INSTANTIATE)) {
                    msgCaption = INSTANCE_INSTANTIATION_MSG;
                    if (instData.isAbstract()) {
                      s = Instantiation.instantiateAbstract(metaInstance, instData.getIdentity());
                    } else {
                      s = Instantiation.instantiateConcrete(metaInstance, instData.getIdentity());
                    }
                  }

                  if (s != null && s.identity().name().equals(instData.getName())) {
                    parent.getMainApplication().getMainWindow().showNotification(msgCaption);
                    ((org.s23m.cell.editor.semanticdomain.Editor) getApplication())
                        .updateContainmentTree();
                    // changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(), null, null);
                    // changeSupport.removePropertyChangeListener(EditorController.getInstance());
                    parent.closeTab(VertexCreationFormLayout.this);
                  } else {
                    parent
                        .getMainApplication()
                        .getMainWindow()
                        .showNotification(
                            "Error", s.identity().name(), Notification.TYPE_ERROR_MESSAGE);
                  }
                }
              }

              private boolean checkForEmptyInstances(final InstantiationData instData) {
                boolean gotEmptyValue = false;
                if (instData.getMetaInstance() == null) {
                  inputForm.setComponentError(
                      new UserError(
                          DefaultFieldFactory.createCaptionByPropertyId(
                                  InstantiationData.METAINSTANCE)
                              + " is missing."));
                  gotEmptyValue = true;
                }
                if (instData.getIdentity() == null) {
                  inputForm.setComponentError(
                      new UserError(
                          DefaultFieldFactory.createCaptionByPropertyId(InstantiationData.IDENTITY)
                              + " is missing."));
                  gotEmptyValue = true;
                }
                return gotEmptyValue;
              }
            });

    final Button closeBtn =
        new Button(
            CANCEL_BUTTON_TEXT,
            new Button.ClickListener() {
              public void buttonClick(final ClickEvent event) {
                inputForm.discard();
                ((org.s23m.cell.editor.semanticdomain.Editor) getApplication())
                    .updateContainmentTree();
                // changeSupport.firePropertyChange(EditorEvents.CHANGESET_MODIFIED.getEventName(),
                // null, null);
                changeSupport.removePropertyChangeListener(EditorController.getInstance());
                parent.closeTab(VertexCreationFormLayout.this);
              }
            });

    okbar.addComponent(okBtn);
    okbar.addComponent(closeBtn);
    okbar.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT);
  }