예제 #1
0
  /**
   * formatCardType.
   *
   * @param card a {@link forge.Card} object.
   * @return a {@link java.lang.String} object.
   */
  public static String formatCardType(Card card) {
    ArrayList<String> list = card.getType();
    StringBuilder sb = new StringBuilder();

    ArrayList<String> superTypes = new ArrayList<String>();
    ArrayList<String> cardTypes = new ArrayList<String>();
    ArrayList<String> subTypes = new ArrayList<String>();
    for (String t : list) {
      if (CardUtil.isASuperType(t)) superTypes.add(t);
      if (CardUtil.isACardType(t)) cardTypes.add(t);
      if (CardUtil.isASubType(t)) subTypes.add(t);
    }

    for (String type : superTypes) {
      sb.append(type).append(" ");
    }
    for (String type : cardTypes) {
      sb.append(type).append(" ");
    }
    if (!subTypes.isEmpty()) sb.append("- ");
    for (String type : subTypes) {
      sb.append(type).append(" ");
    }

    return sb.toString();
  }
  @Nullable
  private ProblemDescriptor[] checkMember(
      final PsiDocCommentOwner docCommentOwner,
      final InspectionManager manager,
      final boolean isOnTheFly) {
    final ArrayList<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>();
    final PsiDocComment docComment = docCommentOwner.getDocComment();
    if (docComment == null) return null;

    final Set<PsiJavaCodeReferenceElement> references = new HashSet<PsiJavaCodeReferenceElement>();
    docComment.accept(getVisitor(references, docCommentOwner, problems, manager, isOnTheFly));
    for (PsiJavaCodeReferenceElement reference : references) {
      final List<PsiClass> classesToImport = new ImportClassFix(reference).getClassesToImport();
      final PsiElement referenceNameElement = reference.getReferenceNameElement();
      problems.add(
          manager.createProblemDescriptor(
              referenceNameElement != null ? referenceNameElement : reference,
              cannotResolveSymbolMessage("<code>" + reference.getText() + "</code>"),
              !isOnTheFly || classesToImport.isEmpty() ? null : new AddImportFix(classesToImport),
              ProblemHighlightType.LIKE_UNKNOWN_SYMBOL,
              isOnTheFly));
    }

    return problems.isEmpty() ? null : problems.toArray(new ProblemDescriptor[problems.size()]);
  }
    @Override
    public Object findElement(String s) {
      List<ObjectWithWeight> elements = new ArrayList<ObjectWithWeight>();
      s = s.trim();
      final ListIterator<Object> it = getElementIterator(0);
      while (it.hasNext()) {
        final ObjectWithWeight o = new ObjectWithWeight(it.next(), s, getComparator());
        if (!o.weights.isEmpty()) {
          elements.add(o);
        }
      }
      ObjectWithWeight cur = null;
      ArrayList<ObjectWithWeight> current = new ArrayList<ObjectWithWeight>();
      for (ObjectWithWeight element : elements) {
        if (cur == null) {
          cur = element;
          current.add(cur);
          continue;
        }

        final int i = element.compareWith(cur);
        if (i == 0) {
          current.add(element);
        } else if (i < 0) {
          cur = element;
          current.clear();
          current.add(cur);
        }
      }

      return current.isEmpty() ? null : findClosestTo(myInitialPsiElement, current);
    }
예제 #4
0
 /**
  * Gets the list of the vnmrj users(operators) for the current unix user logged in
  *
  * @return the list of vnmrj users
  */
 protected Object[] getOperators() {
   String strUser = System.getProperty("user.name");
   User user = LoginService.getDefault().getUser(strUser);
   ArrayList<String> aListOperators = user.getOperators();
   if (aListOperators == null || aListOperators.isEmpty())
     aListOperators = new ArrayList<String>();
   Collections.sort(aListOperators);
   if (aListOperators.contains(strUser)) aListOperators.remove(strUser);
   aListOperators.add(0, strUser);
   return (aListOperators.toArray());
 }
예제 #5
0
 /**
  * Returns the clipboard text.
  *
  * @return text
  */
 private static String clip() {
   // copy selection to clipboard
   final Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard();
   final Transferable tr = clip.getContents(null);
   if (tr != null) {
     final ArrayList<Object> contents = BaseXLayout.contents(tr);
     if (!contents.isEmpty()) return contents.get(0).toString();
   } else {
     Util.debug("Clipboard has no contents.");
   }
   return null;
 }
 @Nullable
 private File[] getFileArray() {
   ArrayList<File> result = new ArrayList<File>();
   TreePath[] selectionPaths = myTree.getSelectionPaths();
   if (selectionPaths != null) {
     for (TreePath selectionPath : selectionPaths) {
       AbstractTreeNode treeNode = (AbstractTreeNode) selectionPath.getLastPathComponent();
       result.addAll(treeNode.getFiles());
     }
   }
   if (result.isEmpty()) return null;
   return result.toArray(new File[result.size()]);
 }
  protected void restoreTree() {
    Pair<ElementNode, List<ElementNode>> selection = storeSelection();

    DefaultMutableTreeNode root = getRootNode();
    if (!myShowClasses || myContainerNodes.isEmpty()) {
      List<ParentNode> otherObjects = new ArrayList<ParentNode>();
      Enumeration<ParentNode> children = getRootNodeChildren();
      ParentNode newRoot =
          new ParentNode(
              null, new MemberChooserObjectBase(getAllContainersNodeName()), new Ref<Integer>(0));
      while (children.hasMoreElements()) {
        final ParentNode nextElement = children.nextElement();
        if (nextElement instanceof ContainerNode) {
          final ContainerNode containerNode = (ContainerNode) nextElement;
          Enumeration<MemberNode> memberNodes = containerNode.children();
          List<MemberNode> memberNodesList = new ArrayList<MemberNode>();
          while (memberNodes.hasMoreElements()) {
            memberNodesList.add(memberNodes.nextElement());
          }
          for (MemberNode memberNode : memberNodesList) {
            newRoot.add(memberNode);
          }
        } else {
          otherObjects.add(nextElement);
        }
      }
      replaceChildren(root, otherObjects);
      sortNode(newRoot, myComparator);
      if (newRoot.children().hasMoreElements()) root.add(newRoot);
    } else {
      Enumeration<ParentNode> children = getRootNodeChildren();
      while (children.hasMoreElements()) {
        ParentNode allClassesNode = children.nextElement();
        Enumeration<MemberNode> memberNodes = allClassesNode.children();
        ArrayList<MemberNode> arrayList = new ArrayList<MemberNode>();
        while (memberNodes.hasMoreElements()) {
          arrayList.add(memberNodes.nextElement());
        }
        Collections.sort(arrayList, myComparator);
        for (MemberNode memberNode : arrayList) {
          myNodeToParentMap.get(memberNode).add(memberNode);
        }
      }
      replaceChildren(root, myContainerNodes);
    }
    myTreeModel.nodeStructureChanged(root);

    defaultExpandTree();

    restoreSelection(selection);
  }
예제 #8
0
  @NotNull
  public List<Pair<TaskInfo, ProgressIndicator>> getBackgroundProcesses() {
    synchronized (myOriginals) {
      if (myOriginals.isEmpty()) return Collections.emptyList();

      List<Pair<TaskInfo, ProgressIndicator>> result =
          new ArrayList<Pair<TaskInfo, ProgressIndicator>>(myOriginals.size());
      for (int i = 0; i < myOriginals.size(); i++) {
        result.add(Pair.<TaskInfo, ProgressIndicator>create(myInfos.get(i), myOriginals.get(i)));
      }

      return Collections.unmodifiableList(result);
    }
  }
    @Nullable
    private Object findClosestTo(PsiElement path, ArrayList<ObjectWithWeight> paths) {
      if (path == null || myInitialPsiElement == null) {
        return paths.get(0).node;
      }
      final Set<PsiElement> parents = getAllParents(myInitialPsiElement);
      ArrayList<ObjectWithWeight> cur = new ArrayList<ObjectWithWeight>();
      int max = -1;
      for (ObjectWithWeight p : paths) {
        final Object last = ((TreePath) p.node).getLastPathComponent();
        final List<PsiElement> elements = new ArrayList<PsiElement>();
        final Object object = ((DefaultMutableTreeNode) last).getUserObject();
        if (object instanceof FilteringTreeStructure.FilteringNode) {
          FilteringTreeStructure.FilteringNode node = (FilteringTreeStructure.FilteringNode) object;
          FilteringTreeStructure.FilteringNode candidate = node;

          while (node != null) {
            elements.add(getPsi(node));
            node = node.getParentNode();
          }
          final int size = ContainerUtil.intersection(parents, elements).size();
          if (size == elements.size() - 1
              && size == parents.size() - (myInitialNodeIsLeaf ? 1 : 0)
              && candidate.children().isEmpty()) {
            return p.node;
          }
          if (size > max) {
            max = size;
            cur.clear();
            cur.add(p);
          } else if (size == max) {
            cur.add(p);
          }
        }
      }

      Collections.sort(
          cur,
          new Comparator<ObjectWithWeight>() {
            @Override
            public int compare(ObjectWithWeight o1, ObjectWithWeight o2) {
              final int i = o1.compareWith(o2);
              return i != 0
                  ? i
                  : ((TreePath) o2.node).getPathCount() - ((TreePath) o1.node).getPathCount();
            }
          });
      return cur.isEmpty() ? null : cur.get(0).node;
    }
예제 #10
0
  private void exportCharacters() {
    Object[] selectedValues = herolabsCharacterList.getSelectedValues();
    HeroLabPathfinderDigester dig = new HeroLabPathfinderDigester();
    boolean success = true;
    ArrayList<Character> notExported = new ArrayList<Character>();

    for (Object object : selectedValues) {
      Character character = (Character) object;
      try {
        if (!dig.saveCharacter(config, character)) {
          notExported.add(character);
        }
      } catch (IOException io) {
        success = false;
        errorDialog(io.getMessage(), "Something bad happened:" + io.toString());

      } catch (SAXException saxe) {
        success = false;
        errorDialog(saxe.getMessage(), "Something bad happened:" + saxe.toString());
      } catch (Exception e) {
        success = false;
        errorDialog(e.getMessage(), "Something bad happened:" + e.toString());
      }
    }

    if (success) {
      String message =
          "Successfully exported "
              + (selectedValues.length - notExported.size())
              + " out of "
              + selectedValues.length
              + " Maptools token(s).";
      if (!notExported.isEmpty()) {
        message +=
            "  "
                + notExported.size()
                + " tokens were not exported as they are not fully configured.";
        // TODO: do something more useful with this collection
      }

      JOptionPane.showMessageDialog(panel, message);
    }
  }
예제 #11
0
 public void run() {
   System.out.println("ReminderServiceOld: Starting at " + new Date());
   while (!l.isEmpty()) {
     Date d = new Date();
     Item i = (Item) l.get(0);
     long interval = i.due.getTime() - d.getTime();
     if (interval > 0) {
       System.out.println("Sleeping until " + i.due);
       try {
         Thread.sleep(interval);
       } catch (InterruptedException e) {
         System.exit(1); // unexpected intr
       }
       message(i.due + ": " + i.message);
     } else message("MISSED " + i.message + " at " + i.due);
     l.remove(0);
   }
   System.exit(0);
 }
예제 #12
0
 public void setSelectedObjectsFromDB() {
   this.selectingObject = true;
   this.list.clearSelection();
   int offsetIdx = 0;
   ArrayList<Integer> selectedIndices = new ArrayList<Integer>();
   for (ObjectStructure s : this.currentChannels) {
     BasicDBList selectedObjects =
         Core.mongoConnector.getSelectedObjects(currentNucId, s.getIdx());
     if (selectedObjects != null && !selectedObjects.isEmpty()) {
       for (Object o : selectedObjects) selectedIndices.add((Integer) o + offsetIdx);
     }
     offsetIdx += s.getObjects().length;
   }
   if (!selectedIndices.isEmpty()) {
     int[] selectedIdx = new int[selectedIndices.size()];
     for (int i = 0; i < selectedIdx.length; i++) selectedIdx[i] = selectedIndices.get(i);
     this.list.setSelectedIndices(selectedIdx);
   }
   this.selectingObject = false;
 }
예제 #13
0
 public void populateObjects() {
   try {
     this.listModel.removeAllElements();
     if (currentChannels == null) {
       return;
     }
     this.populatingObjects = true;
     ArrayList<Integer> selection = null;
     if (showSelection != null && showSelection.isSelected()) selection = new ArrayList<Integer>();
     int currentIdx = 0;
     for (ObjectStructure ass : currentChannels) {
       Object3D[] os = ass.getObjects();
       if (os != null) {
         Object3DGui[] osg = new Object3DGui[os.length];
         for (int i = 0; i < os.length; i++) osg[i] = new Object3DGui(os[i], ass);
         if (layout instanceof ObjectManagerLayout
             && currentChannels.length == 1
             && !((ObjectManagerLayout) layout).getSortKey().equals("idx"))
           this.sort(((ObjectManagerLayout) layout).getSortKey(), osg, ass.getIdx());
         // System.out.println("populating objects.. nb objects:"+os.length);
         for (Object3DGui o3D : osg) {
           this.listModel.addElement(o3D);
           if (selection != null && o3D.isInSelection()) selection.add(currentIdx);
           currentIdx++;
         }
         // if (selection!=null) System.out.println("populating objects.. selection
         // size:"+selection.size());
       } // else System.out.println("no objects int channel:"+ass.getChannelName());
     }
     if (selection != null && !selection.isEmpty()) {
       int[] sel = new int[selection.size()];
       int i = 0;
       for (int idx : selection) sel[i++] = idx;
       list.setSelectedIndices(sel);
     }
   } catch (Exception e) {
     exceptionPrinter.print(e, "", Core.GUIMode);
   }
   this.populatingObjects = false;
 }
  private void restoreSelection(Pair<ElementNode, List<ElementNode>> pair) {
    List<ElementNode> selectedNodes = pair.second;

    DefaultMutableTreeNode root = getRootNode();

    ArrayList<TreePath> toSelect = new ArrayList<TreePath>();
    for (ElementNode node : selectedNodes) {
      DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) node;
      if (root.isNodeDescendant(treeNode)) {
        toSelect.add(new TreePath(treeNode.getPath()));
      }
    }

    if (!toSelect.isEmpty()) {
      myTree.setSelectionPaths(toSelect.toArray(new TreePath[toSelect.size()]));
    }

    ElementNode leadNode = pair.first;
    if (leadNode != null) {
      myTree.setLeadSelectionPath(new TreePath(((DefaultMutableTreeNode) leadNode).getPath()));
    }
  }
 @Nullable
 private static DirectoryChooser.ItemWrapper chooseSelection(
     final VirtualFile initialTargetDirectorySourceRoot,
     final ProjectFileIndex fileIndex,
     final ArrayList<DirectoryChooser.ItemWrapper> items,
     final DirectoryChooser.ItemWrapper initial,
     final DirectoryChooser.ItemWrapper oldOne) {
   if (initial != null || items.contains(NULL_WRAPPER) || items.isEmpty()) {
     return initial;
   } else {
     if (oldOne != null) {
       return oldOne;
     } else if (initialTargetDirectorySourceRoot != null) {
       final boolean inTest = fileIndex.isInTestSourceContent(initialTargetDirectorySourceRoot);
       for (DirectoryChooser.ItemWrapper item : items) {
         final VirtualFile virtualFile = item.getDirectory().getVirtualFile();
         if (fileIndex.isInTestSourceContent(virtualFile) == inTest) {
           return item;
         }
       }
     }
   }
   return items.get(0);
 }
예제 #16
0
파일: Arena.java 프로젝트: pokus001/vivae
  /**
   * Returns a coefficient of the surface the VivaeObject is on or 0 if there is no surface.
   *
   * @param actor
   */
  public float getFrictionOfSurface(VivaeObject actor) {

    ArrayList<Surface> surfacesActorIsOn = new ArrayList<Surface>();
    Surface srfc;
    Area actArea = actor.getArea();

    for (Surface surface : surfaces) {
      srfc = surface;
      Area actor2intersect = (Area) actArea.clone();
      actor2intersect.intersect(srfc.getArea());
      if (!actor2intersect.isEmpty()) {
        surfacesActorIsOn.add(srfc);
      }
    }
    if (surfacesActorIsOn.isEmpty()) {
      return 0f;
    }
    srfc = surfacesActorIsOn.get(surfacesActorIsOn.size() - 1);

    float res = srfc.getFriction();
    //        System.out.println("Surface = " + srfc.getClass().toString() + " has friction " +
    // res);
    return res;
  }
예제 #17
0
 private boolean hasProgressIndicators() {
   synchronized (myOriginals) {
     return !myOriginals.isEmpty();
   }
 }
예제 #18
0
  @Override
  public void actionPerformed(ActionEvent axnEve) {
    Object obj = axnEve.getSource();

    if (obj == selectAllCB) {
      Boolean state;
      if (selectAllCB.isSelected()) {
        state = true;
        deleteBut.setVisible(true);
        if (Home.titlePan.getTitle().equals("Trash")) {
          restoreBut.setVisible(true);
        }
      } else {
        state = false;
        deleteBut.setVisible(false);
        if (Home.titlePan.getTitle().equals("Trash")) {
          restoreBut.setVisible(false);
        }
      }
      for (int i = 0; i < table.getRowCount(); i++) {
        table.setValueAt(state, i, 0);
      }
    } else if (obj == refreshBut || obj == backBut) {
      setContent(Home.titlePan.getTitle());
      backBut.setVisible(false);
    } else if (obj == deleteBut) {
      ArrayList selectedMessages = getSelectedMessages();
      if (selectedMessages.isEmpty()) {
        FootPan.setMessage(FootPan.NO_SELECTION_MESSAGE);
      } else {
        int option =
            JOptionPane.showConfirmDialog(
                Home.home.homeFrame,
                "Are You Sure?",
                "DELETE",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE);
        if (option == 0) {
          Database.deleteMessages(selectedMessages, Home.titlePan.getTitle());
          setContent(Home.titlePan.getTitle());
        }
      }
    } else if (obj == restoreBut) {
      ArrayList selectedMessages = getSelectedMessages();
      if (selectedMessages.isEmpty()) {
        FootPan.setMessage(FootPan.NO_SELECTION_MESSAGE);
      } else {
        int option =
            JOptionPane.showConfirmDialog(
                Home.home.homeFrame,
                "Are You Sure?",
                "RESTORE",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.WARNING_MESSAGE);
        if (option == 0) {
          Database.restoreMessages(selectedMessages);
          setContent(Home.titlePan.getTitle());
        }
      }
    }
  }