Пример #1
0
 private boolean isNodeKeyValid(Integer nodeKey) {
   boolean isValid = false;
   PwPartialPlan partialPlan = partialPlanView.getPartialPlan();
   if ((partialPlanView instanceof TemporalExtentView)
       || (partialPlanView instanceof TokenNetworkView)) {
     if (partialPlan.getToken(nodeKey) != null) {
       return true;
     }
   } else if ((partialPlanView instanceof TimelineView)) {
     if ((partialPlan.getToken(nodeKey) != null) || (partialPlan.getSlot(nodeKey) != null)) {
       return true;
     }
   } else if ((partialPlanView instanceof ConstraintNetworkView)) {
     if ((partialPlan.getToken(nodeKey) != null)
         || (partialPlan.getVariable(nodeKey) != null)
         || (partialPlan.getConstraint(nodeKey) != null)) {
       return true;
     }
   } else {
     System.err.println("AskNodeByKey.isNodeKeyValid: " + partialPlanView + " not handled");
     System.exit(-1);
   }
   return isValid;
 } // end isNodeKeyValid
Пример #2
0
 /**
  * <code>renderEntityPathNodes</code>
  *
  * @param findEntityPath - <code>FindEntityPath</code> -
  * @return - <code>List</code> -
  */
 public List renderEntityPathNodes(final FindEntityPath findEntityPath) {
   boolean isLayoutNeeded = false;
   List nodeList = new ArrayList();
   Iterator entityItr = findEntityPath.getEntityKeyList().iterator();
   PwEntity entity = null;
   boolean isFirstNode = true;
   while (entityItr.hasNext()) {
     Integer entityKey = (Integer) entityItr.next();
     // System.err.println( "key " + entityKey);
     if ((entity = partialPlan.getToken(entityKey)) != null) {
       TokenNavNode tokenNode = null;
       if (isFirstNode) {
         isFirstNode = false;
         tokenNode = (TokenNavNode) renderInitialNode(entity);
         if (didRenderInitialNodeChange) {
           isLayoutNeeded = true;
         }
       } else {
         PwToken token = (PwToken) entity;
         tokenNode = addTokenNavNode(token);
         if (!tokenNode.areNeighborsShown()) {
           if (tokenNode.addTokenObjects(tokenNode)) {
             isLayoutNeeded = true;
           }
           tokenNode.setAreNeighborsShown(true);
         }
       }
       nodeList.add(tokenNode);
     } else if ((entity = partialPlan.getVariable(entityKey)) != null) {
       VariableNavNode variableNode = null;
       if (isFirstNode) {
         isFirstNode = false;
         variableNode = (VariableNavNode) renderInitialNode(entity);
         if (didRenderInitialNodeChange) {
           isLayoutNeeded = true;
         }
       } else {
         PwVariable variable = (PwVariable) entity;
         variableNode = addVariableNavNode(variable);
         if (!variableNode.areNeighborsShown()) {
           if (variableNode.addVariableObjects(variableNode)) {
             isLayoutNeeded = true;
           }
           variableNode.setAreNeighborsShown(true);
         }
       }
       nodeList.add(variableNode);
     } else if ((entity = partialPlan.getConstraint(entityKey)) != null) {
       ConstraintNavNode constraintNode = null;
       if (isFirstNode) {
         isFirstNode = false;
         constraintNode = (ConstraintNavNode) renderInitialNode(entity);
         if (didRenderInitialNodeChange) {
           isLayoutNeeded = true;
         }
       } else {
         PwConstraint constraint = (PwConstraint) entity;
         constraintNode = addConstraintNavNode(constraint);
         if (!constraintNode.areNeighborsShown()) {
           if (constraintNode.addConstraintObjects(constraintNode)) {
             isLayoutNeeded = true;
           }
           constraintNode.setAreNeighborsShown(true);
         }
       }
       nodeList.add(constraintNode);
     } else if ((entity = partialPlan.getRuleInstance(entityKey)) != null) {
       RuleInstanceNavNode ruleInstanceNode = null;
       if (isFirstNode) {
         isFirstNode = false;
         ruleInstanceNode = (RuleInstanceNavNode) renderInitialNode(entity);
         if (didRenderInitialNodeChange) {
           isLayoutNeeded = true;
         }
       } else {
         PwRuleInstance ruleInstance = (PwRuleInstance) entity;
         ruleInstanceNode = addRuleInstanceNavNode(ruleInstance);
         if (!ruleInstanceNode.areNeighborsShown()) {
           if (ruleInstanceNode.addRuleInstanceObjects(ruleInstanceNode)) {
             isLayoutNeeded = true;
           }
           ruleInstanceNode.setAreNeighborsShown(true);
         }
       }
       nodeList.add(ruleInstanceNode);
     } else if ((entity = partialPlan.getSlot(entityKey)) != null) {
       SlotNavNode slotNode = null;
       if (isFirstNode) {
         isFirstNode = false;
         slotNode = (SlotNavNode) renderInitialNode(entity);
         if (didRenderInitialNodeChange) {
           isLayoutNeeded = true;
         }
       } else {
         PwSlot slot = (PwSlot) entity;
         slotNode = addSlotNavNode(slot);
         if (!slotNode.areNeighborsShown()) {
           if (slotNode.addSlotObjects(slotNode)) {
             isLayoutNeeded = true;
           }
           slotNode.setAreNeighborsShown(true);
         }
       }
       nodeList.add(slotNode);
     } else if ((entity = partialPlan.getTimeline(entityKey)) != null) {
       TimelineNavNode timelineNode = null;
       if (isFirstNode) {
         isFirstNode = false;
         timelineNode = (TimelineNavNode) renderInitialNode(entity);
         if (didRenderInitialNodeChange) {
           isLayoutNeeded = true;
         }
       } else {
         PwTimeline timeline = (PwTimeline) entity;
         timelineNode = addTimelineNavNode(timeline);
         if (!timelineNode.areNeighborsShown()) {
           if (timelineNode.addTimelineObjects(timelineNode)) {
             isLayoutNeeded = true;
           }
           timelineNode.setAreNeighborsShown(true);
         }
       }
       nodeList.add(timelineNode);
     } else if ((entity = partialPlan.getResource(entityKey)) != null) {
       ResourceNavNode resourceNode = null;
       if (isFirstNode) {
         isFirstNode = false;
         resourceNode = (ResourceNavNode) renderInitialNode(entity);
         if (didRenderInitialNodeChange) {
           isLayoutNeeded = true;
         }
       } else {
         PwResource resource = (PwResource) entity;
         resourceNode = addResourceNavNode(resource);
         if (!resourceNode.areNeighborsShown()) {
           if (resourceNode.addResourceObjects(resourceNode)) {
             isLayoutNeeded = true;
           }
           resourceNode.setAreNeighborsShown(true);
         }
       }
       nodeList.add(resourceNode);
     } else if ((entity = partialPlan.getObject(entityKey)) != null) {
       // PwObject must be last
       ModelClassNavNode objectNode = null;
       if (isFirstNode) {
         isFirstNode = false;
         objectNode = (ModelClassNavNode) renderInitialNode(entity);
         if (didRenderInitialNodeChange) {
           isLayoutNeeded = true;
         }
       } else {
         PwObject object = (PwObject) entity;
         objectNode = addModelClassNavNode(object);
         if (!objectNode.areNeighborsShown()) {
           if (objectNode.addObjects(objectNode)) {
             isLayoutNeeded = true;
           }
           objectNode.setAreNeighborsShown(true);
         }
       }
       nodeList.add(objectNode);
     } else {
       System.err.println(
           "NavigatorView.renderEntityPathNodes: entityKey " + entityKey + " not handled");
     }
   }
   if (isLayoutNeeded) {
     // System.err.println( "NavigatorView.renderEntityPathNodes: setLayoutNeeded");
     setLayoutNeeded();
   }
   setFocusNode(null);
   highlightPathNodesList = nodeList;
   redraw();
   return nodeList;
 } // end renderEntityPathNodes