コード例 #1
0
 /**
  * <code>findAndSelectResource</code>
  *
  * @param resourceToFind - <code>PwResource</code> -
  * @param xLoc - <code>int</code> -
  */
 public final void findAndSelectResource(final PwResource resourceToFind, final int xLoc) {
   boolean isResourceFound = false;
   Iterator resourceSetListItr = resourceTransactionSetList.iterator();
   while (resourceSetListItr.hasNext()) {
     ResourceTransactionSet resourceTransactionSet =
         (ResourceTransactionSet) resourceSetListItr.next();
     //       System.err.println( "resourceToFind id = " + resourceToFind.getId() +
     //                           " resource id = " +
     // resourceTransactionSet.getResource().getId());
     if (resourceTransactionSet.getResource().getId().equals(resourceToFind.getId())) {
       System.err.println(
           "ResourceTransactionView found resource: "
               + resourceToFind.getName()
               + " (key="
               + resourceToFind.getId().toString()
               + ")");
       isResourceFound = true;
       this.getJGoLevelScaleViewSelection().clearSelection();
       this.getJGoExtentViewSelection().clearSelection();
       this.getJGoExtentViewHScrollBar()
           .setValue(Math.max(0, (int) (xLoc - (this.getJGoExtentViewSize().getWidth() / 2))));
       this.getJGoExtentViewVScrollBar()
           .setValue(
               Math.max(
                   0,
                   (int)
                       (findResourceYLoc(resourceToFind)
                           - (this.getJGoExtentViewSize().getHeight() / 2))));
       Iterator nameNodeItr = resourceNameNodeList.iterator();
       while (nameNodeItr.hasNext()) {
         ResourceNameNode nameNode = (ResourceNameNode) nameNodeItr.next();
         if (nameNode.getResource().getId().equals(resourceToFind.getId())) {
           this.getJGoLevelScaleViewSelection().extendSelection(nameNode);
           break;
         }
       }
     }
   }
   if (!isResourceFound) {
     // Content Spec filtering may cause this to happen
     String message =
         "Resource '"
             + resourceToFind.getName()
             + "' (key="
             + resourceToFind.getId().toString()
             + ") not found.";
     JOptionPane.showMessageDialog(
         PlanWorks.getPlanWorks(),
         message,
         "Resource Not Found in ResourceTransactionView",
         JOptionPane.ERROR_MESSAGE);
     System.err.println(message);
   }
 } // end findAndSelectResource
コード例 #2
0
 private int findResourceYLoc(final PwResource resourceToFind) {
   int yLoc = 0;
   Iterator resourceTransSetItr = resourceTransactionSetList.iterator();
   while (resourceTransSetItr.hasNext()) {
     ResourceTransactionSet resourceTransSet = (ResourceTransactionSet) resourceTransSetItr.next();
     if (resourceToFind.getId().equals(resourceTransSet.getResource().getId())) {
       return resourceTransSet.getTransactionSetYOrigin();
     }
   }
   return yLoc;
 } // end findResourceYLoc
コード例 #3
0
 /**
  * <code>findNearestResource</code>
  *
  * @param dCoords - <code>Point</code> -
  * @return - <code>PwResource</code> -
  */
 protected final PwResource findNearestResource(final Point dCoords) {
   int docY = (int) dCoords.getY();
   PwResource resourceCandidate = null;
   Iterator reourceTransSetItr = resourceTransactionSetList.iterator();
   while (reourceTransSetItr.hasNext()) {
     ResourceTransactionSet resourceTransSet = (ResourceTransactionSet) reourceTransSetItr.next();
     if (docY >= resourceTransSet.getTransactionSetYOrigin()) {
       resourceCandidate = resourceTransSet.getResource();
     } else {
       break;
     }
   }
   return resourceCandidate;
 } // end findNearestResource
コード例 #4
0
 /**
  * <code>findAndSelectResourceTransaction</code>
  *
  * @param resourceTransToFind - <code>PwResourceTransaction</code> -
  */
 public final void findAndSelectResourceTransaction(
     final PwResourceTransaction resourceTransToFind) {
   boolean isResourceTransFound = false;
   if ((resourceTransToFind.getParentId() != null)
       && (!resourceTransToFind.getParentId().equals(DbConstants.NO_ID))) {
     PwResource resourceToFind =
         (PwResource) partialPlan.getObject(resourceTransToFind.getParentId());
     //       System.err.println( "findAndSelectResourceTransaction resourceToFind " +
     //                           resourceToFind);
     Iterator resourceSetListItr = resourceTransactionSetList.iterator();
     foundIt:
     while (resourceSetListItr.hasNext()) {
       ResourceTransactionSet resourceTransactionSet =
           (ResourceTransactionSet) resourceSetListItr.next();
       if (resourceTransactionSet.getResource().getId().equals(resourceToFind.getId())) {
         Iterator transNodeItr = resourceTransactionSet.getTransactionNodeList().iterator();
         while (transNodeItr.hasNext()) {
           ResourceTransactionNode transNode = (ResourceTransactionNode) transNodeItr.next();
           if (transNode.getTransaction().getId().equals(resourceTransToFind.getId())) {
             System.err.println(
                 "ResourceTransactionView found resourceTransaction: "
                     + resourceTransToFind.getName()
                     + " (key="
                     + resourceTransToFind.getId().toString()
                     + ")");
             isResourceTransFound = true;
             this.getJGoLevelScaleViewSelection().clearSelection();
             this.getJGoExtentViewSelection().clearSelection();
             this.getJGoExtentViewHScrollBar()
                 .setValue(
                     Math.max(
                         0,
                         (int)
                             (transNode.getLocation().getX()
                                 - (this.getJGoExtentViewSize().getWidth() / 2))));
             this.getJGoExtentViewVScrollBar()
                 .setValue(
                     Math.max(
                         0,
                         (int)
                             (transNode.getLocation().getY()
                                 - (this.getJGoExtentViewSize().getHeight() / 2))));
             this.getJGoExtentViewSelection().extendSelection(transNode);
             break foundIt;
           }
         }
       }
     }
     if (!isResourceTransFound) {
       // Content Spec filtering may cause this to happen
       String message =
           "Resource Transaction'"
               + resourceTransToFind.getName()
               + "' (key="
               + resourceTransToFind.getId().toString()
               + ") not found.";
       JOptionPane.showMessageDialog(
           PlanWorks.getPlanWorks(),
           message,
           "Resource TransactionNot Found in ResourceTransactionView",
           JOptionPane.ERROR_MESSAGE);
       System.err.println(message);
     }
   }
 } // end findAndSelectResourceTransaction