Exemplo n.º 1
1
  /**
   * Returns the value of the component
   *
   * @param nLineInd index of the line in the file.
   */
  protected String getValue(int nLineInd) {
    JComponent comp = null;
    String strValue = null;

    // Get the component corresponding to the line of the file from the list.
    if (nLineInd < m_aListComp.size()) {
      comp = (JComponent) m_aListComp.get(nLineInd);
    }

    if (comp == null) return strValue;

    // Get the value of the component
    if (comp instanceof JTextField) strValue = ((JTextField) comp).getText();
    else if (comp instanceof JCheckBox) strValue = ((JCheckBox) comp).isSelected() ? "yes" : "no";
    else if (comp instanceof JComboBox) strValue = (String) ((JComboBox) comp).getSelectedItem();

    // if the value is of the form: $home, then parse the value
    /*if (strValue.indexOf('$') >= 0)
    {
        String strNewValue = WFileUtil.parseValue(strValue, new HashMap());
        if (strNewValue != null && strNewValue.trim().length() > 0)
            strValue = strNewValue;
    }*/

    return strValue;
  }
Exemplo n.º 2
0
 /**
  * getCard.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @param name a {@link java.lang.String} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getCard(ArrayList<Card> cards, String name) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     if (c.getName().equals(name)) ret.add(c);
   }
   return ret;
 }
Exemplo n.º 3
0
  public void switchLayout(int newId, boolean bLayout) {

    if (layoutId == newId) return;
    if (newId >= nviews) updateVpInfo(newId + 1);

    if (bSwitching) {
      return;
    }

    bSwitching = true;
    int oldId = layoutId;
    vpId = newId;
    layoutId = newId;

    recordCurrentLayout();
    VpLayoutInfo vInfo = Util.getViewArea().getLayoutInfo(oldId);
    if (vInfo != null) { // save current layout info
      vInfo.tp_selectedTab = tp_selectedTab;
      vInfo.setVerticalTabName(selectedTabName);
      // copyCurrentLayout(vInfo);
    }

    vInfo = Util.getViewArea().getLayoutInfo(newId);

    putHsLayout(oldId);
    if (bLayout) getHsLayout(vpId);

    for (int i = 0; i < toolList.size(); i++)
      ((VToolPanel) toolList.get(i)).switchLayout(newId, bLayout);

    if (bLayout) setCurrentLayout();
    /*
    if(comparePanelLayout(oldId, newId)) {
    setCurrentLayout();
           }
           if ((vInfo != null) && vInfo.bAvailable &&
    compareCurrentLayout(vInfo)) {
                  setCurrentLayout(vInfo);
           }

    for(int i=0; i< toolList.size(); i++)
        ((VToolPanel) toolList.get(i)).switchLayout(newId);
           */

    // setViewPort(newId);

    if (bLayout) setCurrentLayout(vInfo);

    updateValue();

    if (bLayout) {
      if (pinPanel.isOpen()) {
        if (!pinPanel.isVisible()) pinPanel.setVisible(true);
      } else pinPanel.setVisible(false);
    }
    validate();
    repaint();

    bSwitching = false;
  }
  @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()]);
  }
Exemplo n.º 5
0
  private void updateVpInfo() {

    String key;
    String vps;
    for (int j = 0; j < keys.size(); j++) {
      key = (String) keys.get(j);
      vps = (String) vpInfo.get(j);
      if (vps == null || vps.length() <= 0 || vps.equals("all")) {
        for (int i = 0; i < nviews; i++) {
          tp_paneInfo[i].put(key, "yes");
        }
      } else {
        for (int i = 0; i < nviews; i++) tp_paneInfo[i].put(key, "no");
        StringTokenizer tok = new StringTokenizer(vps, " ,\n");
        while (tok.hasMoreTokens()) {
          int vp = Integer.valueOf(tok.nextToken()).intValue();
          vp--;
          if (vp >= 0 && vp < nviews) {
            tp_paneInfo[vp].remove(key);
            tp_paneInfo[vp].put(key, "yes");
          }
        }
      }
    }
  }
  private static List<XmlElementDescriptor> computeRequiredSubTags(XmlElementsGroup group) {

    if (group.getMinOccurs() < 1) return Collections.emptyList();
    switch (group.getGroupType()) {
      case LEAF:
        XmlElementDescriptor descriptor = group.getLeafDescriptor();
        return descriptor == null
            ? Collections.<XmlElementDescriptor>emptyList()
            : Collections.singletonList(descriptor);
      case CHOICE:
        LinkedHashSet<XmlElementDescriptor> set = null;
        for (XmlElementsGroup subGroup : group.getSubGroups()) {
          List<XmlElementDescriptor> descriptors = computeRequiredSubTags(subGroup);
          if (set == null) {
            set = new LinkedHashSet<XmlElementDescriptor>(descriptors);
          } else {
            set.retainAll(descriptors);
          }
        }
        if (set == null || set.isEmpty()) {
          return Collections.singletonList(null); // placeholder for smart completion
        }
        return new ArrayList<XmlElementDescriptor>(set);

      default:
        ArrayList<XmlElementDescriptor> list = new ArrayList<XmlElementDescriptor>();
        for (XmlElementsGroup subGroup : group.getSubGroups()) {
          list.addAll(computeRequiredSubTags(subGroup));
        }
        return list;
    }
  }
Exemplo n.º 7
0
  public ArrayList<String> getMoveList() {
    moveList.clear();
    if (piece == 0) {
      setListForKing();
    }
    if (piece == 1) {
      setListForQueen();
    }
    if (piece == 2) {
      moveList.clear();
      squareList.clear();
      setListForRook();
    }
    if (piece == 3) {
      setListForKnight();
    }
    if (piece == 4) {
      setListForBishop();
    }
    if (piece == 5) {
      setAttacksForPawn();
    }

    return moveList;
  }
 /**
  * From the dialog collects roots and commits to be pushed.
  *
  * @return roots to be pushed.
  */
 private Collection<Root> getRootsToPush() {
   final ArrayList<Root> rootsToPush = new ArrayList<Root>();
   for (int i = 0; i < myTreeRoot.getChildCount(); i++) {
     CheckedTreeNode node = (CheckedTreeNode) myTreeRoot.getChildAt(i);
     Root r = (Root) node.getUserObject();
     if (r.remoteName == null || r.commits.size() == 0) {
       continue;
     }
     boolean topCommit = true;
     for (int j = 0; j < node.getChildCount(); j++) {
       if (node.getChildAt(j) instanceof CheckedTreeNode) {
         CheckedTreeNode commitNode = (CheckedTreeNode) node.getChildAt(j);
         if (commitNode.isChecked()) {
           Commit commit = (Commit) commitNode.getUserObject();
           if (!topCommit) {
             r.commitToPush = commit.revision.asString();
           }
           rootsToPush.add(r);
           break;
         }
         topCommit = false;
       }
     }
   }
   return rootsToPush;
 }
Exemplo n.º 9
0
 public String[] getAdditionalIconNames() {
   ArrayList<String> result = new ArrayList<String>();
   String[] sa = new String[0];
   if (myEnd instanceof PsiMethod) {
     PsiMethod m = (PsiMethod) myEnd;
     if (m.getModifierList().hasModifierProperty(PsiModifier.PUBLIC)) {
       result.add("nodes/c_public");
     } else if (m.getModifierList().hasModifierProperty(PsiModifier.PROTECTED)) {
       result.add("nodes/c_protected");
     } else if (m.getModifierList().hasModifierProperty(PsiModifier.PRIVATE)) {
       result.add("nodes/c_private");
     } else {
       result.add("nodes/c_plocal");
     }
     if ((getModifiers() & ModifierConstants.IMPLEMENTING) != 0) {
       result.add("gutter/implementingMethod");
     }
     if ((getModifiers() & ModifierConstants.IMPLEMENTED) != 0) {
       result.add("gutter/implementedMethod");
     }
     if ((getModifiers() & ModifierConstants.OVERRIDING) != 0) {
       result.add("gutter/overridingMethod");
     }
     if ((getModifiers() & ModifierConstants.OVERRIDDEN) != 0) {
       result.add("gutter/overridenMethod");
     }
   }
   return result.toArray(sa);
 }
Exemplo n.º 10
0
  /** Shuffle the numbers on the buttons */
  private void shuffle() {
    // Randomize the order
    if (solution) solution = false;
    else Collections.shuffle(current);

    // Reset the stats
    moves = 0;
    solved = false;

    // Reset each of the buttons to reflect the randomized
    // order
    for (int i = 0; i < buttons.size(); i++) {
      JButton b = (JButton) buttons.get(i);
      String value = (String) current.get(i);
      int val = Integer.parseInt(value) - 1;
      b.setText(value);
      b.setBackground(java.awt.Color.orange);
      b.setIcon(icons[val]);
      if (value.equals("16")) {
        b.setVisible(false);
        hiddenIndex = i;
      } else {
        b.setVisible(true);
      }
    }

    // Reset the status line
    getStatusLabel().setText("Number of moves: " + moves);
  }
Exemplo n.º 11
0
  /**
   * When the user has to specify file names, he can use wildcards (*, ?). This methods handles the
   * usage of these wildcards.
   *
   * @param path The path were to search
   * @param s Wilcards
   * @param sort Set to true will sort file names
   * @return An array of String which contains all files matching <code>s</code> in current
   *     directory.
   */
  public static String[] getWildCardMatches(String path, String s, boolean sort) {
    if (s == null) return null;

    String files[];
    String filesThatMatch[];
    String args = new String(s.trim());
    ArrayList filesThatMatchVector = new ArrayList();

    if (path == null) path = getUserDirectory();

    files = (new File(path)).list();
    if (files == null) return null;

    for (int i = 0; i < files.length; i++) {
      if (match(args, files[i])) {
        File temp = new File(getUserDirectory(), files[i]);
        filesThatMatchVector.add(new String(temp.getName()));
      }
    }

    Object[] o = filesThatMatchVector.toArray();
    filesThatMatch = new String[o.length];
    for (int i = 0; i < o.length; i++) filesThatMatch[i] = o[i].toString();
    o = null;
    filesThatMatchVector = null;

    if (sort) Arrays.sort(filesThatMatch);

    return filesThatMatch;
  }
Exemplo n.º 12
0
  void handleScanFiles(JTextField field, String[] extensions) {
    String[] dataFiles = scanDataFolderForFilesByType(extensions);
    if (dataFiles == null || dataFiles.length == 0) return;

    String[] oldFileList = field.getText().trim().split(",");
    ArrayList<String> newFileList = new ArrayList<String>();
    for (String c : oldFileList) {
      c = c.trim();
      if (!c.equals("") && newFileList.indexOf(c) == -1) // TODO check exists() here?
      {
        newFileList.add(c);
      }
    }
    for (String c : dataFiles) {
      c = c.trim();
      if (!c.equals("") && newFileList.indexOf(c) == -1) {
        newFileList.add(c);
      }
    }
    Collections.sort(newFileList);
    String finalFileList = "";
    int i = 0;
    for (String s : newFileList) {
      finalFileList += (i > 0 ? ", " : "") + s;
      i++;
    }
    field.setText(finalFileList);
  }
Exemplo n.º 13
0
 /**
  * setupConnectedCards.
  *
  * @param connectedCards a {@link java.util.ArrayList} object.
  */
 public static void setupConnectedCards(ArrayList<CardPanel> connectedCards) {
   for (int i = connectedCards.size() - 1; i > 0; i--) {
     // System.out.println("We should have a stack");
     CardPanel cp = connectedCards.get(i);
     cp.connectedCard = connectedCards.get(i - 1);
   }
 }
Exemplo n.º 14
0
  /**
   * getNonBasicLand.
   *
   * @param cards a {@link java.util.ArrayList} object.
   * @param landName a {@link java.lang.String} object.
   * @return a {@link java.util.ArrayList} object.
   */
  public static ArrayList<Card> getNonBasicLand(ArrayList<Card> cards, String landName) {
    ArrayList<Card> ret = new ArrayList<Card>();

    for (Card c : cards) if (c.getName().equals(landName)) ret.add(c);

    return ret;
  }
Exemplo n.º 15
0
 public void bringToFront(Figure figure) {
   if (children.remove(figure)) {
     children.add(figure);
     needsSorting = true;
     fireAreaInvalidated(figure.getDrawingArea());
   }
 }
Exemplo n.º 16
0
 private void createPainToTree3true(
     final DefaultTreeModel treeModel, DefaultMutableTreeNode root, Collection paintCollection) {
   ArrayList a = (ArrayList) paintCollection;
   Iterator i = a.iterator();
   Person p = null;
   Person parent = null;
   DefaultMutableTreeNode parentNode = root;
   DefaultMutableTreeNode newNode;
   while (i.hasNext()) {
     p = (Person) i.next();
     int ves, ves2;
     if (parent != null) {
       parent = (Person) parentNode.getUserObject();
       ves = comparePerson(p, (Person) parentNode.getUserObject());
       ves2 = comparePersonAsString(p, (Person) parentNode.getUserObject()) + 1;
       System.out.println("ves = " + ves + " ves2= " + ves2);
       switch (ves) {
         case 0:
           {
             parentNode = root;
             parent = null;
             break;
           }
         case 1:
           {
           }
       }
     }
     newNode = new DefaultMutableTreeNode(p);
     parentNode.add(newNode);
     parent = p;
     parentNode = newNode;
   }
 }
Exemplo n.º 17
0
 public void sendToBack(Figure figure) {
   if (children.remove(figure)) {
     children.add(0, figure);
     needsSorting = true;
     fireAreaInvalidated(figure.getDrawingArea());
   }
 }
 public TestType1CFont(InputStream is) throws IOException {
   super();
   setPreferredSize(new Dimension(800, 800));
   addKeyListener(this);
   BufferedInputStream bis = new BufferedInputStream(is);
   int count = 0;
   ArrayList<byte[]> al = new ArrayList<byte[]>();
   byte b[] = new byte[32000];
   int len;
   while ((len = bis.read(b, 0, b.length)) >= 0) {
     byte[] c = new byte[len];
     System.arraycopy(b, 0, c, 0, len);
     al.add(c);
     count += len;
     b = new byte[32000];
   }
   data = new byte[count];
   len = 0;
   for (int i = 0; i < al.size(); i++) {
     byte from[] = al.get(i);
     System.arraycopy(from, 0, data, len, from.length);
     len += from.length;
   }
   pos = 0;
   //	printData();
   parse();
   // TODO: free up (set to null) unused structures (data, subrs, stack)
 }
  // check if sudo password is correct (so sudo can be used in all other scripts, even without
  // password, lasts for 5 minutes)
  private void doSudoCmd() {
    String pass = passwordField.getText();

    File file = null;
    try {
      // write file in /tmp
      file = new File("/tmp/cmd_sudo.sh"); // ""c:/temp/run.bat""
      FileOutputStream fos = new FileOutputStream(file);
      fos.write("echo $password | sudo -S ls\nexit $?".getBytes()); // "echo $password > pipo.txt"
      fos.close();

      // execute
      HashMap vars = new HashMap();
      vars.put("password", pass);

      List oses = new ArrayList();
      oses.add(
          new OsConstraint(
              "unix", null, null,
              null)); // "windows",System.getProperty("os.name"),System.getProperty("os.version"),System.getProperty("os.arch")));

      ArrayList plist = new ArrayList();
      ParsableFile pf = new ParsableFile(file.getAbsolutePath(), null, null, oses);
      plist.add(pf);
      ScriptParser sp = new ScriptParser(plist, new VariableSubstitutor(vars));
      sp.parseFiles();

      ArrayList elist = new ArrayList();
      ExecutableFile ef =
          new ExecutableFile(
              file.getAbsolutePath(),
              ExecutableFile.POSTINSTALL,
              ExecutableFile.ABORT,
              oses,
              false);
      elist.add(ef);
      FileExecutor fe = new FileExecutor(elist);
      int retval = fe.executeFiles(ExecutableFile.POSTINSTALL, this);
      if (retval == 0) {
        idata.setVariable("password", pass);
        isValid = true;
      }
      //			else is already showing dialog
      //			{
      //				JOptionPane.showMessageDialog(this, "Cannot execute 'sudo' cmd, check your password",
      // "Error", JOptionPane.ERROR_MESSAGE);
      //			}
    } catch (Exception e) {
      //				JOptionPane.showMessageDialog(this, "Cannot execute 'sudo' cmd, check your password",
      // "Error", JOptionPane.ERROR_MESSAGE);
      e.printStackTrace();
      isValid = false;
    }
    try {
      if (file != null && file.exists())
        file.delete(); // you don't want the file with password tobe arround, in case of error
    } catch (Exception e) {
      // ignore
    }
  }
Exemplo n.º 20
0
  /** Pastes Items from the Clipboard on the Board */
  public void paste() {

    ComponentSelection clipboardContent = (ComponentSelection) tbe.getClipboard().getContents(this);

    if ((clipboardContent != null)
        && (clipboardContent.isDataFlavorSupported(ComponentSelection.itemFlavor))) {

      Object[] tempItems = null;
      try {
        tempItems =
            board.cloneItems(clipboardContent.getTransferData(ComponentSelection.itemFlavor));
      } catch (UnsupportedFlavorException e1) {

        e1.printStackTrace();
      }
      ItemComponent[] items = new ItemComponent[tempItems.length];
      for (int i = 0; i < tempItems.length; i++) {
        items[i] = (ItemComponent) tempItems[i];
      }
      PasteCommand del = new PasteCommand(items);
      ArrayList<Command> actCommands = new ArrayList<Command>();
      actCommands.add(del);
      tbe.addCommands(actCommands);
      board.addItem(items);
    }
  }
Exemplo n.º 21
0
  public boolean moveValid(Square candidateSquare) {
    if (piece == 0) {
      setListForKing();
    }
    if (piece == 1) {
      setListForQueen();
    }
    if (piece == 2) {
      moveList.clear();
      setListForRook();
    }
    if (piece == 3) {
      setListForKnight();
    }
    if (piece == 4) {
      setListForBishop();
    }

    if (piece == 5) {
      setListForPawn();
    }

    if (moveList.contains(candidateSquare.getPosition())) {
      return true;
    }
    return false;
  }
 private List<InjInfo> getSelectedInjections() {
   final ArrayList<InjInfo> toRemove = new ArrayList<InjInfo>();
   for (int row : myInjectionsTable.getSelectedRows()) {
     toRemove.add(myInjectionsTable.getItems().get(myInjectionsTable.convertRowIndexToModel(row)));
   }
   return toRemove;
 }
Exemplo n.º 23
0
 /**
  * Returns all editors.
  *
  * @return editors
  */
 EditorArea[] editors() {
   final ArrayList<EditorArea> edits = new ArrayList<EditorArea>();
   for (final Component c : tabs.getComponents()) {
     if (c instanceof EditorArea) edits.add((EditorArea) c);
   }
   return edits.toArray(new EditorArea[edits.size()]);
 }
Exemplo n.º 24
0
 public void totalExport() {
   File expf = new File("export");
   if (expf.exists()) rmrf(expf);
   expf.mkdirs();
   for (int sto = 0; sto < storeLocs.size(); sto++) {
     try {
       String sl =
           storeLocs.get(sto).getAbsolutePath().replaceAll("/", "-").replaceAll("\\\\", "-");
       File estore = new File(expf, sl);
       estore.mkdir();
       File log = new File(estore, LIBRARY_NAME);
       PrintWriter pw = new PrintWriter(log);
       for (int i = 0; i < store.getRowCount(); i++)
         if (store.curStore(i) == sto) {
           File enc = store.locate(i);
           File dec = sec.prepareMainFile(enc, estore, false);
           pw.println(dec.getName());
           pw.println(store.getValueAt(i, Storage.COL_DATE));
           pw.println(store.getValueAt(i, Storage.COL_TAGS));
           synchronized (jobs) {
             jobs.addLast(expJob(enc, dec));
           }
         }
       pw.close();
     } catch (IOException exc) {
       exc.printStackTrace();
       JOptionPane.showMessageDialog(frm, "Exporting Failed");
       return;
     }
   }
   JOptionPane.showMessageDialog(frm, "Exporting to:\n   " + expf.getAbsolutePath());
 }
Exemplo n.º 25
0
  public void putHsLayout(int id) {
    Hashtable hs = sshare.userInfo();
    if (hs == null) return;
    String key, name;
    JComponent obj;
    PushpinIF pobj;

    for (int i = 0; i < keys.size(); i++) {
      key = (String) keys.get(i);
      obj = (JComponent) panes.get(key);
      if (obj != null && (obj instanceof PushpinIF)) {
        pobj = (PushpinIF) obj;
        name = "tabTool." + id + "." + pobj.getName() + ".";
        hs.put(name + "refY", new Float(pobj.getRefY()));
        hs.put(name + "refX", new Float(pobj.getRefX()));
        hs.put(name + "refH", new Float(pobj.getRefH()));
        key = "open";
        if (pobj.isHide()) key = "hide";
        else if (pobj.isClose()) key = "close";
        hs.put(name + "status", key);
      }
    }
    /*
    name = "tabTool."+id+".TabPanel.";
    key = pinPanel.getLastName();
    if (key != null)
       hs.put(name+"lastName", key);
    key = "open";
    if (pinPanel.isHide())
       key = "hide";
    else if (pinPanel.isClose())
       key = "close";
    hs.put(name+"status", key);
     */
  }
Exemplo n.º 26
0
  /** Flashes the visual bell. This class has no other public API. */
  public void flash() {
    if (GuiUtilities.isMacOs()) {
      // Mac OS has a system-wide "visual bell" that looks much better than ours.
      // You can turn this on in the Universal Access preference pane, by checking "Flash the screen
      // when an alert sound occurs".
      // We can take advantage of Apple's hard work if the user has this turned on by "actually"
      // ringing the bell.
      // This doesn't change our "no noise pollution" policy, if you ignore the very unlikely race
      // condition.
      ArrayList<String> result = new ArrayList<String>();
      ArrayList<String> errors = new ArrayList<String>();
      int status =
          ProcessUtilities.backQuote(
              null,
              new String[] {
                "defaults",
                "-currentHost",
                "read",
                "Apple Global Domain",
                "com.apple.sound.beep.flash"
              },
              result,
              errors);
      if (status == 0 && errors.size() == 0 && result.size() == 1 && result.get(0).equals("1")) {
        Toolkit.getDefaultToolkit().beep();
        return;
      }
    }

    setBellVisibility(true);
    timer.restart();
  }
Exemplo n.º 27
0
  public void addProgress(@NotNull ProgressIndicatorEx original, @NotNull TaskInfo info) {
    synchronized (myOriginals) {
      final boolean veryFirst = !hasProgressIndicators();

      myOriginals.add(original);
      myInfos.add(info);

      final InlineProgressIndicator expanded = createInlineDelegate(info, original, false);
      final InlineProgressIndicator compact = createInlineDelegate(info, original, true);

      myPopup.addIndicator(expanded);
      myProgressIcon.resume();

      if (veryFirst && !myPopup.isShowing()) {
        buildInInlineIndicator(compact);
      } else {
        buildInProcessCount();
        if (myInfos.size() > 1 && Registry.is("ide.windowSystem.autoShowProcessPopup")) {
          openProcessPopup(false);
        }
      }

      runQuery();
    }
  }
  @NotNull
  public EditorWindow[] getOrderedWindows() {
    final ArrayList<EditorWindow> res = new ArrayList<EditorWindow>();

    // Collector for windows in tree ordering:
    class Inner {
      final void collect(final JPanel panel) {
        final Component comp = panel.getComponent(0);
        if (comp instanceof Splitter) {
          final Splitter splitter = (Splitter) comp;
          collect((JPanel) splitter.getFirstComponent());
          collect((JPanel) splitter.getSecondComponent());
        } else if (comp instanceof JPanel || comp instanceof JBTabs) {
          final EditorWindow window = findWindowWith(comp);
          if (window != null) {
            res.add(window);
          }
        }
      }
    }

    // get root component and traverse splitters tree:
    if (getComponentCount() != 0) {
      final Component comp = getComponent(0);
      LOG.assertTrue(comp instanceof JPanel);
      final JPanel panel = (JPanel) comp;
      if (panel.getComponentCount() != 0) {
        new Inner().collect(panel);
      }
    }

    LOG.assertTrue(res.size() == myWindows.size());
    return res.toArray(new EditorWindow[res.size()]);
  }
  public void createBuildings() {
    bList = new ArrayList<Building>();

    // resource
    bList.add(new Building("Gold Mine", 3, 3, 960, 7));
    bList.add(new Building("Elixir Collector", 3, 3, 960, 7));
    // bList.add(new Building("Dark Elixir Drill", 3, 3, 1160, 3));
    bList.add(new Building("Gold Storage", 3, 3, 2100, 4));
    bList.add(new Building("Elixir Storage", 3, 3, 2100, 4));
    // bList.add(new Building("Dark Elixir Storage", 3, 3, 3200, 1));
    // bList.add(new Building("Builder Hut", 2, 2, 250, 5));

    // army
    bList.add(new Building("Army Camp", 5, 5, 500, 4));
    bList.add(new Building("Barracks", 3, 3, 860, 4));
    // bList.add(new Building("Dark Barracks", 3, 3, 900, 2));
    // bList.add(new Building("Laboratory", 4, 4, 950, 1));
    // bList.add(new Building("Spell Factory", 3, 3, 615, 1));
    // bList.add(new Building("Barbarian King Altar", 3, 3, 250, 1));
    // bList.add(new Building("Dark Spell Factory", 3, 3, 750, 1));
    // bList.add(new Building("Archer Queen Altar", 3, 3, 250, 1));

    // other
    bList.add(new Building("Town Hall", 4, 4, 5500, 1));
    bList.add(new Building("Clan Castle", 3, 3, 3400, 1));

    // defense
    bList.add(new Building("Archer Tower", 3, 3, 1050, 7));
    bList.add(new Building("Cannon", 3, 3, 1260, 6));
    bList.add(new Building("Wall", 1, 1, 7000, 275));
    // bList.add(new Building("Air Sweeper", 2, 2, 1000, 2));
    // bList.add(new Building("Cannon", 3, 3, 1260, 6));
    // bList.add(new Building("Cannon", 3, 3, 1260, 6));
  }
Exemplo n.º 30
0
 /**
  * getGlobalEnchantments.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getGlobalEnchantments(ArrayList<Card> cards) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     if (c.isGlobalEnchantment() && !c.isCreature()) ret.add(c);
   }
   return ret;
 }