Search in sources :

Example 1 with ProgressPanel

use of jadx.gui.ui.panel.ProgressPanel in project jadx by skylot.

the class MainWindow method initUI.

private void initUI() {
    setMinimumSize(new Dimension(200, 150));
    mainPanel = new JPanel(new BorderLayout());
    splitPane = new JSplitPane();
    splitPane.setResizeWeight(SPLIT_PANE_RESIZE_WEIGHT);
    mainPanel.add(splitPane);
    DefaultMutableTreeNode treeRootNode = new DefaultMutableTreeNode(NLS.str("msg.open_file"));
    treeModel = new DefaultTreeModel(treeRootNode);
    tree = new JTree(treeModel);
    ToolTipManager.sharedInstance().registerComponent(tree);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setFocusable(false);
    tree.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(FocusEvent e) {
            tree.setFocusable(false);
        }
    });
    tree.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e)) {
                if (!nodeClickAction(getJNodeUnderMouse(e))) {
                    // click ignored -> switch to focusable mode
                    tree.setFocusable(true);
                    tree.requestFocus();
                }
            } else if (SwingUtilities.isRightMouseButton(e)) {
                treeRightClickAction(e);
            }
        }
    });
    tree.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                nodeClickAction(tree.getLastSelectedPathComponent());
            }
        }
    });
    tree.setCellRenderer(new DefaultTreeCellRenderer() {

        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean isLeaf, int row, boolean focused) {
            Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, isLeaf, row, focused);
            if (value instanceof JNode) {
                JNode jNode = (JNode) value;
                setText(jNode.makeStringHtml());
                setIcon(jNode.getIcon());
                setToolTipText(jNode.getTooltip());
            } else {
                setToolTipText(null);
            }
            if (value instanceof JPackage) {
                setEnabled(((JPackage) value).isEnabled());
            }
            return c;
        }
    });
    tree.addTreeWillExpandListener(new TreeWillExpandListener() {

        @Override
        public void treeWillExpand(TreeExpansionEvent event) {
            TreePath path = event.getPath();
            Object node = path.getLastPathComponent();
            if (node instanceof JLoadableNode) {
                ((JLoadableNode) node).loadNode();
            }
            if (!treeReloading) {
                project.addTreeExpansion(getPathExpansion(event.getPath()));
                update();
            }
        }

        @Override
        public void treeWillCollapse(TreeExpansionEvent event) {
            if (!treeReloading) {
                project.removeTreeExpansion(getPathExpansion(event.getPath()));
                update();
            }
        }
    });
    progressPane = new ProgressPanel(this, true);
    IssuesPanel issuesPanel = new IssuesPanel(this);
    JPanel leftPane = new JPanel(new BorderLayout());
    JScrollPane treeScrollPane = new JScrollPane(tree);
    treeScrollPane.setMinimumSize(new Dimension(100, 150));
    JPanel bottomPane = new JPanel(new BorderLayout());
    bottomPane.add(issuesPanel, BorderLayout.PAGE_START);
    bottomPane.add(progressPane, BorderLayout.PAGE_END);
    leftPane.add(treeScrollPane, BorderLayout.CENTER);
    leftPane.add(bottomPane, BorderLayout.PAGE_END);
    splitPane.setLeftComponent(leftPane);
    tabbedPane = new TabbedPane(this);
    tabbedPane.setMinimumSize(new Dimension(150, 150));
    splitPane.setRightComponent(tabbedPane);
    new DropTarget(this, DnDConstants.ACTION_COPY, new MainDropTarget(this));
    heapUsageBar = new HeapUsageBar();
    mainPanel.add(heapUsageBar, BorderLayout.SOUTH);
    verticalSplitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    verticalSplitter.setTopComponent(splitPane);
    verticalSplitter.setResizeWeight(SPLIT_PANE_RESIZE_WEIGHT);
    mainPanel.add(verticalSplitter, BorderLayout.CENTER);
    setContentPane(mainPanel);
    setTitle(DEFAULT_TITLE);
}
Also used : JPanel(javax.swing.JPanel) FocusAdapter(java.awt.event.FocusAdapter) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) JLoadableNode(jadx.gui.treemodel.JLoadableNode) KeyAdapter(java.awt.event.KeyAdapter) IssuesPanel(jadx.gui.ui.panel.IssuesPanel) FocusEvent(java.awt.event.FocusEvent) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) KeyEvent(java.awt.event.KeyEvent) BorderLayout(java.awt.BorderLayout) JNode(jadx.gui.treemodel.JNode) Component(java.awt.Component) TreeExpansionEvent(javax.swing.event.TreeExpansionEvent) TreeWillExpandListener(javax.swing.event.TreeWillExpandListener) JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) ProgressPanel(jadx.gui.ui.panel.ProgressPanel) MouseAdapter(java.awt.event.MouseAdapter) JPackage(jadx.gui.treemodel.JPackage) Dimension(java.awt.Dimension) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) CacheObject(jadx.gui.utils.CacheObject) DropTarget(java.awt.dnd.DropTarget) JSplitPane(javax.swing.JSplitPane)

Example 2 with ProgressPanel

use of jadx.gui.ui.panel.ProgressPanel in project jadx by skylot.

the class CommonSearchDialog method initButtonsPanel.

@NotNull
protected JPanel initButtonsPanel() {
    progressPane = new ProgressPanel(mainWindow, false);
    JButton cancelButton = new JButton(NLS.str("search_dialog.cancel"));
    cancelButton.addActionListener(event -> dispose());
    JButton openBtn = new JButton(NLS.str("search_dialog.open"));
    openBtn.addActionListener(event -> openSelectedItem());
    getRootPane().setDefaultButton(openBtn);
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    JCheckBox cbKeepOpen = new JCheckBox(NLS.str("search_dialog.keep_open"));
    cbKeepOpen.setSelected(mainWindow.getSettings().getKeepCommonDialogOpen());
    cbKeepOpen.addActionListener(e -> {
        mainWindow.getSettings().setKeepCommonDialogOpen(cbKeepOpen.isSelected());
        mainWindow.getSettings().sync();
    });
    buttonPane.add(cbKeepOpen);
    buttonPane.add(Box.createRigidArea(new Dimension(15, 0)));
    buttonPane.add(progressPane);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(openBtn);
    buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPane.add(cancelButton);
    return buttonPane;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) ProgressPanel(jadx.gui.ui.panel.ProgressPanel) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ProgressPanel (jadx.gui.ui.panel.ProgressPanel)2 Dimension (java.awt.Dimension)2 JPanel (javax.swing.JPanel)2 JLoadableNode (jadx.gui.treemodel.JLoadableNode)1 JNode (jadx.gui.treemodel.JNode)1 JPackage (jadx.gui.treemodel.JPackage)1 IssuesPanel (jadx.gui.ui.panel.IssuesPanel)1 CacheObject (jadx.gui.utils.CacheObject)1 BorderLayout (java.awt.BorderLayout)1 Component (java.awt.Component)1 DropTarget (java.awt.dnd.DropTarget)1 FocusAdapter (java.awt.event.FocusAdapter)1 FocusEvent (java.awt.event.FocusEvent)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 BoxLayout (javax.swing.BoxLayout)1 JButton (javax.swing.JButton)1 JCheckBox (javax.swing.JCheckBox)1