Ejemplo n.º 1
0
  public void hilightScript(SWF swf, String name) {
    TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
    TreeItem scriptsNode = ttm.getScriptsNode(swf);
    if (scriptsNode instanceof ClassesListTreeModel) {
      ClassesListTreeModel clModel = (ClassesListTreeModel) scriptsNode;
      ScriptPack pack = null;
      for (ScriptPack item : clModel.getList()) {
        ClassPath classPath = item.getClassPath();

        // first check the className to avoid calling unnecessary toString
        if (name.endsWith(classPath.className) && classPath.toString().equals(name)) {
          pack = item;
          break;
        }
      }
      if (pack != null) {
        hilightScript(pack);
      }
    }
  }
Ejemplo n.º 2
0
  public boolean search(final String txt, boolean ignoreCase, boolean regexp) {
    if ((txt != null) && (!txt.isEmpty())) {
      searchPanel.setOptions(ignoreCase, regexp);
      TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
      TreeItem scriptsNode = ttm.getScriptsNode(mainPanel.getCurrentSwf());
      final List<ABCPanelSearchResult> found = new ArrayList<>();
      if (scriptsNode instanceof ClassesListTreeModel) {
        ClassesListTreeModel clModel = (ClassesListTreeModel) scriptsNode;
        List<ScriptPack> allpacks = clModel.getList();
        final Pattern pat =
            regexp
                ? Pattern.compile(
                    txt, ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0)
                : Pattern.compile(
                    Pattern.quote(txt),
                    ignoreCase ? (Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : 0);
        int pos = 0;
        for (final ScriptPack pack : allpacks) {
          pos++;
          String workText = AppStrings.translate("work.searching");
          String decAdd = "";
          if (!SWF.isCached(pack)) {
            decAdd = ", " + AppStrings.translate("work.decompiling");
          }

          try {
            CancellableWorker worker =
                new CancellableWorker() {

                  @Override
                  public Void doInBackground() throws Exception {
                    if (pat.matcher(SWF.getCached(pack).text).find()) {
                      ABCPanelSearchResult searchResult = new ABCPanelSearchResult();
                      searchResult.scriptPack = pack;
                      found.add(searchResult);
                    }
                    return null;
                  }
                };
            worker.execute();
            Main.startWork(
                workText
                    + " \""
                    + txt
                    + "\""
                    + decAdd
                    + " - ("
                    + pos
                    + "/"
                    + allpacks.size()
                    + ") "
                    + pack.getClassPath().toString()
                    + "... ",
                worker);
            worker.get();
          } catch (InterruptedException ex) {
            break;
          } catch (ExecutionException ex) {
            Logger.getLogger(ABCPanel.class.getName()).log(Level.SEVERE, null, ex);
          }
        }
      }

      Main.stopWork();

      searchPanel.setSearchText(txt);

      View.execInEventDispatch(
          () -> {
            SearchResultsDialog<ABCPanelSearchResult> sr =
                new SearchResultsDialog<>(
                    ABCPanel.this.mainPanel.getMainFrame().getWindow(), txt, ABCPanel.this);
            sr.setResults(found);
            sr.setVisible(true);
          });

      return true;

      // return searchPanel.setResults(found);
    }
    return false;
  }