示例#1
0
  public void showCard(final String name, final Trait trait) {
    View.execInEventDispatch(
        () -> {
          CardLayout layout = (CardLayout) innerPanel.getLayout();
          layout.show(innerPanel, name);
          boolean b = cardMap.get(name) instanceof TraitDetail;
          boolean drun;
          synchronized (this) {
            buttonsShouldBeShown = b;
            drun = debugRunning;
          }
          buttonsPanel.setVisible(b && !drun);

          TraitDetail newDetail = null;
          if (b) {
            newDetail = (TraitDetail) cardMap.get(name);
          }
          for (JComponent v : cardMap.values()) {
            if (v instanceof TraitDetail) {
              if (v != newDetail) {
                TraitDetail oldDetail = (TraitDetail) v;
                oldDetail.setActive(false);
              }
            }
          }
          if (newDetail != null) {
            newDetail.setActive(true);
          }

          selectedCard = name;
          selectedLabel.setText(selectedCard);
          if (trait == null) {
            traitNameLabel.setText("-");
          } else {
            if (abcPanel != null) {
              traitNameLabel.setText(
                  trait.getName(abcPanel.abc).getName(abcPanel.abc.constants, null, false));
            }
          }
        });
  }
示例#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;
  }