コード例 #1
0
 public void updateConstList() {
   switch (constantTypeList.getSelectedIndex()) {
     case 0:
       View.autoResizeColWidth(constantTable, new UIntTableModel(abc));
       break;
     case 1:
       View.autoResizeColWidth(constantTable, new IntTableModel(abc));
       break;
     case 2:
       View.autoResizeColWidth(constantTable, new DoubleTableModel(abc));
       break;
     case 3:
       View.autoResizeColWidth(constantTable, new DecimalTableModel(abc));
       break;
     case 4:
       View.autoResizeColWidth(constantTable, new StringTableModel(abc));
       break;
     case 5:
       View.autoResizeColWidth(constantTable, new NamespaceTableModel(abc));
       break;
     case 6:
       View.autoResizeColWidth(constantTable, new NamespaceSetTableModel(abc));
       break;
     case 7:
       View.autoResizeColWidth(constantTable, new MultinameTableModel(abc));
       break;
   }
   // DefaultTableColumnModel colModel  = (DefaultTableColumnModel) constantTable.getColumnModel();
   // colModel.getColumn(0).setMaxWidth(50);
 }
コード例 #2
0
  public ABCPanel(MainPanel mainPanel) {

    this.mainPanel = mainPanel;
    setLayout(new BorderLayout());

    decompiledTextArea = new DecompiledEditorPane(this);
    decompiledTextArea.addTextChangedListener(this::decompiledTextAreaTextChanged);

    decompiledTextArea.setLinkHandler(
        new LinkHandler() {

          @Override
          public boolean isLink(Token token) {
            return hasDeclaration(token.length == 1 ? token.start : token.start + 1);
          }

          @Override
          public void handleLink(Token token) {
            gotoDeclaration(token.length == 1 ? token.start : token.start + 1);
          }

          @Override
          public Highlighter.HighlightPainter linkPainter() {
            return decompiledTextArea.linkPainter();
          }
        });

    searchPanel = new SearchPanel<>(new FlowLayout(), this);

    decompiledScrollPane = new JScrollPane(decompiledTextArea);

    JPanel iconDecPanel = new JPanel();
    iconDecPanel.setLayout(new BoxLayout(iconDecPanel, BoxLayout.Y_AXIS));
    JPanel iconsPanel = new JPanel();
    iconsPanel.setLayout(new BoxLayout(iconsPanel, BoxLayout.X_AXIS));

    JButton newTraitButton = new JButton(View.getIcon("traitadd16"));
    newTraitButton.setMargin(new Insets(5, 5, 5, 5));
    newTraitButton.addActionListener(this::addTraitButtonActionPerformed);
    newTraitButton.setToolTipText(AppStrings.translate("button.addtrait"));
    iconsPanel.add(newTraitButton);

    scriptNameLabel = new JLabel("-");
    scriptNameLabel.setAlignmentX(0);
    iconsPanel.setAlignmentX(0);
    decompiledScrollPane.setAlignmentX(0);
    iconDecPanel.add(scriptNameLabel);
    iconDecPanel.add(iconsPanel);
    iconDecPanel.add(decompiledScrollPane);

    JPanel decButtonsPan = new JPanel(new FlowLayout());
    decButtonsPan.setBorder(new BevelBorder(BevelBorder.RAISED));
    decButtonsPan.add(editDecompiledButton);
    decButtonsPan.add(experimentalLabel);
    decButtonsPan.add(saveDecompiledButton);
    decButtonsPan.add(cancelDecompiledButton);

    editDecompiledButton.setMargin(new Insets(3, 3, 3, 10));
    saveDecompiledButton.setMargin(new Insets(3, 3, 3, 10));
    cancelDecompiledButton.setMargin(new Insets(3, 3, 3, 10));

    saveDecompiledButton.addActionListener(this::saveDecompiledButtonActionPerformed);
    editDecompiledButton.addActionListener(this::editDecompiledButtonActionPerformed);
    cancelDecompiledButton.addActionListener(this::cancelDecompiledButtonActionPerformed);

    saveDecompiledButton.setVisible(false);
    cancelDecompiledButton.setVisible(false);
    decButtonsPan.setAlignmentX(0);

    JPanel decPanel = new JPanel(new BorderLayout());
    decPanel.add(searchPanel, BorderLayout.NORTH);
    decPanel.add(iconDecPanel, BorderLayout.CENTER);
    decPanel.add(decButtonsPan, BorderLayout.SOUTH);
    detailPanel = new DetailPanel(this);
    JPanel panB = new JPanel();
    panB.setLayout(new BorderLayout());
    panB.add(decPanel, BorderLayout.CENTER);
    panB.add(decLabel, BorderLayout.NORTH);
    decLabel.setHorizontalAlignment(SwingConstants.CENTER);
    // decLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
    splitPane =
        new JPersistentSplitPane(
            JSplitPane.HORIZONTAL_SPLIT,
            panB,
            detailPanel,
            Configuration.guiAvm2SplitPaneDividerLocationPercent);
    splitPane.setContinuousLayout(true);

    decompiledTextArea.changeContentType("text/actionscript");
    decompiledTextArea.setFont(
        new Font("Monospaced", Font.PLAIN, decompiledTextArea.getFont().getSize()));

    View.addEditorAction(
        decompiledTextArea,
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int multinameIndex = decompiledTextArea.getMultinameUnderCaret();
            if (multinameIndex > -1) {
              UsageFrame usageFrame = new UsageFrame(abc, multinameIndex, ABCPanel.this, false);
              usageFrame.setVisible(true);
            }
          }
        },
        "find-usages",
        AppStrings.translate("abc.action.find-usages"),
        "control U");

    View.addEditorAction(
        decompiledTextArea,
        new AbstractAction() {
          @Override
          public void actionPerformed(ActionEvent e) {
            gotoDeclaration(decompiledTextArea.getCaretPosition());
          }
        },
        "find-declaration",
        AppStrings.translate("abc.action.find-declaration"),
        "control B");

    CtrlClickHandler cch = new CtrlClickHandler();
    decompiledTextArea.addKeyListener(cch);
    decompiledTextArea.addMouseListener(cch);
    decompiledTextArea.addMouseMotionListener(cch);

    navigator = new TraitsList(this);

    navPanel = new JPanel(new BorderLayout());
    JPanel navIconsPanel = new JPanel();
    navIconsPanel.setLayout(new BoxLayout(navIconsPanel, BoxLayout.X_AXIS));
    final JToggleButton sortButton = new JToggleButton(View.getIcon("sort16"));
    sortButton.setMargin(new Insets(3, 3, 3, 3));
    navIconsPanel.add(sortButton);
    navPanel.add(navIconsPanel, BorderLayout.SOUTH);
    navPanel.add(new JScrollPane(navigator), BorderLayout.CENTER);
    sortButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            navigator.setSorted(sortButton.isSelected());
            navigator.updateUI();
          }
        });

    tabbedPane = new JTabbedPane();
    tabbedPane.addTab(AppStrings.translate("traits"), navPanel);
    add(splitPane, BorderLayout.CENTER);

    JPanel panConstants = new JPanel();
    panConstants.setLayout(new BorderLayout());

    constantTypeList =
        new JComboBox<>(
            new String[] {
              "UINT", "INT", "DOUBLE", "DECIMAL", "STRING", "NAMESPACE", "NAMESPACESET", "MULTINAME"
            });
    constantTable = new JTable();
    if (abc != null) {
      View.autoResizeColWidth(constantTable, new UIntTableModel(abc));
    }
    constantTable.setAutoCreateRowSorter(true);

    final ABCPanel t = this;
    constantTable.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              if (constantTypeList.getSelectedIndex() == 7) { // MULTINAME
                int rowIndex = constantTable.getSelectedRow();
                if (rowIndex == -1) {
                  return;
                }
                int multinameIndex = constantTable.convertRowIndexToModel(rowIndex);
                if (multinameIndex > 0) {
                  UsageFrame usageFrame = new UsageFrame(abc, multinameIndex, t, false);
                  usageFrame.setVisible(true);
                }
              }
            }
          }
        });
    constantTypeList.addItemListener(this);
    panConstants.add(constantTypeList, BorderLayout.NORTH);
    panConstants.add(new JScrollPane(constantTable), BorderLayout.CENTER);
    tabbedPane.addTab(AppStrings.translate("constants"), panConstants);
  }