Search in sources :

Example 56 with JToolBar

use of javax.swing.JToolBar in project zaproxy by zaproxy.

the class ActiveScanPanel method addToolBarElements.

@Override
protected int addToolBarElements(JToolBar panelToolbar, Location loc, int x) {
    // Override to add elements into the toolbar
    if (Location.start.equals(loc)) {
        panelToolbar.add(getPolicyManagerButton(), getGBC(x++, 0));
    }
    if (Location.beforeProgressBar.equals(loc)) {
        panelToolbar.add(getProgressButton(), getGBC(x++, 0));
    }
    if (Location.afterProgressBar.equals(loc)) {
        panelToolbar.add(new JToolBar.Separator(), getGBC(x++, 0));
        panelToolbar.add(new JLabel(Constant.messages.getString("ascan.toolbar.requests.label")), getGBC(x++, 0));
        panelToolbar.add(getNumRequests(), getGBC(x++, 0));
        panelToolbar.add(new JToolBar.Separator(), getGBC(x++, 0));
        panelToolbar.add(new JLabel(Constant.messages.getString("ascan.toolbar.newalerts.label")), getGBC(x++, 0));
        panelToolbar.add(getNumNewAlerts(), getGBC(x++, 0));
        panelToolbar.add(new JToolBar.Separator(), getGBC(x++, 0));
        panelToolbar.add(getExportButton(), getGBC(x++, 0));
    }
    return x;
}
Also used : JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar)

Example 57 with JToolBar

use of javax.swing.JToolBar in project jadx by skylot.

the class MainWindow method initMenuAndToolbar.

private void initMenuAndToolbar() {
    Action openAction = new AbstractAction(NLS.str("file.open_action"), ICON_OPEN) {

        @Override
        public void actionPerformed(ActionEvent e) {
            openFileOrProject();
        }
    };
    openAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.open_action"));
    openAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_O, UiUtils.ctrlButton()));
    Action addFilesAction = new AbstractAction(NLS.str("file.add_files_action"), ICON_ADD_FILES) {

        @Override
        public void actionPerformed(ActionEvent e) {
            addFiles();
        }
    };
    addFilesAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.add_files_action"));
    newProjectAction = new AbstractAction(NLS.str("file.new_project")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            newProject();
        }
    };
    newProjectAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.new_project"));
    saveProjectAction = new AbstractAction(NLS.str("file.save_project")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveProject();
        }
    };
    saveProjectAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.save_project"));
    Action saveProjectAsAction = new AbstractAction(NLS.str("file.save_project_as")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveProjectAs();
        }
    };
    saveProjectAsAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.save_project_as"));
    Action saveAllAction = new AbstractAction(NLS.str("file.save_all"), ICON_SAVE_ALL) {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveAll(false);
        }
    };
    saveAllAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.save_all"));
    saveAllAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_S, UiUtils.ctrlButton()));
    Action exportAction = new AbstractAction(NLS.str("file.export_gradle"), ICON_EXPORT) {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveAll(true);
        }
    };
    exportAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.export_gradle"));
    exportAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_E, UiUtils.ctrlButton()));
    JMenu recentProjects = new JMenu(NLS.str("menu.recent_projects"));
    recentProjects.addMenuListener(new RecentProjectsMenuListener(recentProjects));
    Action prefsAction = new AbstractAction(NLS.str("menu.preferences"), ICON_PREF) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new JadxSettingsWindow(MainWindow.this, settings).setVisible(true);
        }
    };
    prefsAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.preferences"));
    prefsAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_P, UiUtils.ctrlButton() | KeyEvent.SHIFT_DOWN_MASK));
    Action exitAction = new AbstractAction(NLS.str("file.exit"), ICON_EXIT) {

        @Override
        public void actionPerformed(ActionEvent e) {
            closeWindow();
        }
    };
    isFlattenPackage = settings.isFlattenPackage();
    flatPkgMenuItem = new JCheckBoxMenuItem(NLS.str("menu.flatten"), ICON_FLAT_PKG);
    flatPkgMenuItem.setState(isFlattenPackage);
    JCheckBoxMenuItem heapUsageBarMenuItem = new JCheckBoxMenuItem(NLS.str("menu.heapUsageBar"));
    heapUsageBarMenuItem.setState(settings.isShowHeapUsageBar());
    heapUsageBarMenuItem.addActionListener(event -> {
        settings.setShowHeapUsageBar(!settings.isShowHeapUsageBar());
        heapUsageBar.setVisible(settings.isShowHeapUsageBar());
    });
    JCheckBoxMenuItem alwaysSelectOpened = new JCheckBoxMenuItem(NLS.str("menu.alwaysSelectOpened"));
    alwaysSelectOpened.setState(settings.isAlwaysSelectOpened());
    alwaysSelectOpened.addActionListener(event -> {
        settings.setAlwaysSelectOpened(!settings.isAlwaysSelectOpened());
        if (settings.isAlwaysSelectOpened()) {
            this.syncWithEditor();
        }
    });
    Action syncAction = new AbstractAction(NLS.str("menu.sync"), ICON_SYNC) {

        @Override
        public void actionPerformed(ActionEvent e) {
            syncWithEditor();
        }
    };
    syncAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.sync"));
    syncAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_T, UiUtils.ctrlButton()));
    Action textSearchAction = new AbstractAction(NLS.str("menu.text_search"), ICON_SEARCH) {

        @Override
        public void actionPerformed(ActionEvent e) {
            ContentPanel panel = tabbedPane.getSelectedCodePanel();
            if (panel instanceof AbstractCodeContentPanel) {
                AbstractCodeArea codeArea = ((AbstractCodeContentPanel) panel).getCodeArea();
                String preferText = codeArea.getSelectedText();
                if (StringUtils.isEmpty(preferText)) {
                    preferText = codeArea.getWordUnderCaret();
                }
                if (!StringUtils.isEmpty(preferText)) {
                    SearchDialog.searchText(MainWindow.this, preferText);
                    return;
                }
            }
            SearchDialog.search(MainWindow.this, SearchDialog.SearchPreset.TEXT);
        }
    };
    textSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.text_search"));
    textSearchAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_F, UiUtils.ctrlButton() | KeyEvent.SHIFT_DOWN_MASK));
    Action clsSearchAction = new AbstractAction(NLS.str("menu.class_search"), ICON_FIND) {

        @Override
        public void actionPerformed(ActionEvent e) {
            SearchDialog.search(MainWindow.this, SearchDialog.SearchPreset.CLASS);
        }
    };
    clsSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.class_search"));
    clsSearchAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_N, UiUtils.ctrlButton()));
    Action commentSearchAction = new AbstractAction(NLS.str("menu.comment_search"), ICON_COMMENT_SEARCH) {

        @Override
        public void actionPerformed(ActionEvent e) {
            SearchDialog.search(MainWindow.this, SearchDialog.SearchPreset.COMMENT);
        }
    };
    commentSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.comment_search"));
    commentSearchAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_SEMICOLON, UiUtils.ctrlButton() | KeyEvent.SHIFT_DOWN_MASK));
    Action deobfAction = new AbstractAction(NLS.str("menu.deobfuscation"), ICON_DEOBF) {

        @Override
        public void actionPerformed(ActionEvent e) {
            toggleDeobfuscation();
        }
    };
    deobfAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("preferences.deobfuscation"));
    deobfAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_D, UiUtils.ctrlButton() | KeyEvent.ALT_DOWN_MASK));
    deobfToggleBtn = new JToggleButton(deobfAction);
    deobfToggleBtn.setSelected(settings.isDeobfuscationOn());
    deobfToggleBtn.setText("");
    deobfMenuItem = new JCheckBoxMenuItem(deobfAction);
    deobfMenuItem.setState(settings.isDeobfuscationOn());
    Action logAction = new AbstractAction(NLS.str("menu.log"), ICON_LOG) {

        @Override
        public void actionPerformed(ActionEvent e) {
            LogViewerDialog.open(MainWindow.this);
        }
    };
    logAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.log"));
    logAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_L, UiUtils.ctrlButton() | KeyEvent.SHIFT_DOWN_MASK));
    Action aboutAction = new AbstractAction(NLS.str("menu.about"), ICON_INFO) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new AboutDialog().setVisible(true);
        }
    };
    Action backAction = new AbstractAction(NLS.str("nav.back"), ICON_BACK) {

        @Override
        public void actionPerformed(ActionEvent e) {
            tabbedPane.navBack();
        }
    };
    backAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("nav.back"));
    backAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_ESCAPE, 0));
    Action forwardAction = new AbstractAction(NLS.str("nav.forward"), ICON_FORWARD) {

        @Override
        public void actionPerformed(ActionEvent e) {
            tabbedPane.navForward();
        }
    };
    forwardAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("nav.forward"));
    forwardAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.ALT_DOWN_MASK, SystemInfo.IS_MAC));
    Action quarkAction = new AbstractAction("Quark Engine", ICON_QUARK) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new QuarkDialog(MainWindow.this).setVisible(true);
        }
    };
    quarkAction.putValue(Action.SHORT_DESCRIPTION, "Quark Engine");
    Action openDeviceAction = new AbstractAction(NLS.str("debugger.process_selector"), ICON_DEBUGGER) {

        @Override
        public void actionPerformed(ActionEvent e) {
            ADBDialog dialog = new ADBDialog(MainWindow.this);
            dialog.setVisible(true);
        }
    };
    openDeviceAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.process_selector"));
    JMenu file = new JMenu(NLS.str("menu.file"));
    file.setMnemonic(KeyEvent.VK_F);
    file.add(openAction);
    file.add(addFilesAction);
    file.addSeparator();
    file.add(newProjectAction);
    file.add(saveProjectAction);
    file.add(saveProjectAsAction);
    file.addSeparator();
    file.add(saveAllAction);
    file.add(exportAction);
    file.addSeparator();
    file.add(recentProjects);
    file.addSeparator();
    file.add(prefsAction);
    file.addSeparator();
    file.add(exitAction);
    JMenu view = new JMenu(NLS.str("menu.view"));
    view.setMnemonic(KeyEvent.VK_V);
    view.add(flatPkgMenuItem);
    view.add(syncAction);
    view.add(heapUsageBarMenuItem);
    view.add(alwaysSelectOpened);
    JMenu nav = new JMenu(NLS.str("menu.navigation"));
    nav.setMnemonic(KeyEvent.VK_N);
    nav.add(textSearchAction);
    nav.add(clsSearchAction);
    nav.add(commentSearchAction);
    nav.addSeparator();
    nav.add(backAction);
    nav.add(forwardAction);
    JMenu tools = new JMenu(NLS.str("menu.tools"));
    tools.setMnemonic(KeyEvent.VK_T);
    tools.add(deobfMenuItem);
    tools.add(quarkAction);
    tools.add(openDeviceAction);
    JMenu help = new JMenu(NLS.str("menu.help"));
    help.setMnemonic(KeyEvent.VK_H);
    help.add(logAction);
    help.add(aboutAction);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(file);
    menuBar.add(view);
    menuBar.add(nav);
    menuBar.add(tools);
    menuBar.add(help);
    setJMenuBar(menuBar);
    flatPkgButton = new JToggleButton(ICON_FLAT_PKG);
    flatPkgButton.setSelected(isFlattenPackage);
    ActionListener flatPkgAction = e -> toggleFlattenPackage();
    flatPkgMenuItem.addActionListener(flatPkgAction);
    flatPkgButton.addActionListener(flatPkgAction);
    flatPkgButton.setToolTipText(NLS.str("menu.flatten"));
    updateLink = new Link("", JadxUpdate.JADX_RELEASES_URL);
    updateLink.setVisible(false);
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    toolbar.add(openAction);
    toolbar.add(addFilesAction);
    toolbar.addSeparator();
    toolbar.add(saveAllAction);
    toolbar.add(exportAction);
    toolbar.addSeparator();
    toolbar.add(syncAction);
    toolbar.add(flatPkgButton);
    toolbar.addSeparator();
    toolbar.add(textSearchAction);
    toolbar.add(clsSearchAction);
    toolbar.add(commentSearchAction);
    toolbar.addSeparator();
    toolbar.add(backAction);
    toolbar.add(forwardAction);
    toolbar.addSeparator();
    toolbar.add(deobfToggleBtn);
    toolbar.add(quarkAction);
    toolbar.add(openDeviceAction);
    toolbar.addSeparator();
    toolbar.add(logAction);
    toolbar.addSeparator();
    toolbar.add(prefsAction);
    toolbar.addSeparator();
    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(updateLink);
    mainPanel.add(toolbar, BorderLayout.NORTH);
}
Also used : DropTarget(java.awt.dnd.DropTarget) Arrays(java.util.Arrays) Link(jadx.gui.utils.Link) AbstractCodeArea(jadx.gui.ui.codearea.AbstractCodeArea) GraphicsEnvironment(java.awt.GraphicsEnvironment) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JadxSettings(jadx.gui.settings.JadxSettings) SearchDialog(jadx.gui.ui.dialog.SearchDialog) EMPTY_RUNNABLE(io.reactivex.internal.functions.Functions.EMPTY_RUNNABLE) ExportTask(jadx.gui.jobs.ExportTask) SummaryNode(jadx.gui.ui.treenodes.SummaryNode) JFileChooser(javax.swing.JFileChooser) TimerTask(java.util.TimerTask) JFrame(javax.swing.JFrame) Path(java.nio.file.Path) FileUtils(jadx.core.utils.files.FileUtils) EnumSet(java.util.EnumSet) JToolBar(javax.swing.JToolBar) Release(jadx.gui.update.data.Release) FileUtils.fileNamesToPaths(jadx.gui.utils.FileUtils.fileNamesToPaths) ToolTipManager(javax.swing.ToolTipManager) TreePath(javax.swing.tree.TreePath) StringUtils(jadx.core.utils.StringUtils) Set(java.util.Set) ContentPanel(jadx.gui.ui.panel.ContentPanel) KeyEvent(java.awt.event.KeyEvent) WindowAdapter(java.awt.event.WindowAdapter) Component(java.awt.Component) Executors(java.util.concurrent.Executors) Box(javax.swing.Box) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractAction(javax.swing.AbstractAction) AboutDialog(jadx.gui.ui.dialog.AboutDialog) JadxProject(jadx.gui.settings.JadxProject) JPanel(javax.swing.JPanel) WindowConstants(javax.swing.WindowConstants) AbstractCodeContentPanel(jadx.gui.ui.codearea.AbstractCodeContentPanel) ActionListener(java.awt.event.ActionListener) JSplitPane(javax.swing.JSplitPane) TreeExpansionEvent(javax.swing.event.TreeExpansionEvent) TaskStatus(jadx.gui.jobs.TaskStatus) DnDConstants(java.awt.dnd.DnDConstants) Action(javax.swing.Action) KeyAdapter(java.awt.event.KeyAdapter) ArrayList(java.util.ArrayList) JumpPosition(jadx.gui.utils.JumpPosition) ImageIcon(javax.swing.ImageIcon) CacheObject(jadx.gui.utils.CacheObject) QuarkDialog(jadx.gui.plugins.quark.QuarkDialog) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) JMethod(jadx.gui.treemodel.JMethod) ResourceFile(jadx.api.ResourceFile) ProgressPanel(jadx.gui.ui.panel.ProgressPanel) Files(java.nio.file.Files) TreeSelectionModel(javax.swing.tree.TreeSelectionModel) MouseEvent(java.awt.event.MouseEvent) JScrollPane(javax.swing.JScrollPane) JadxSettingsWindow(jadx.gui.settings.JadxSettingsWindow) JadxUpdate(jadx.gui.update.JadxUpdate) MenuEvent(javax.swing.event.MenuEvent) JavaNode(jadx.api.JavaNode) FontUtils(jadx.gui.utils.FontUtils) Utils(jadx.core.utils.Utils) IndexTask(jadx.gui.jobs.IndexTask) JDebuggerPanel(jadx.gui.ui.panel.JDebuggerPanel) SystemInfo(jadx.gui.utils.SystemInfo) LogViewerDialog(jadx.gui.ui.dialog.LogViewerDialog) JDialog(javax.swing.JDialog) LafManager(jadx.gui.utils.LafManager) JToggleButton(javax.swing.JToggleButton) LoggerFactory(org.slf4j.LoggerFactory) Timer(java.util.Timer) IndexService(jadx.gui.jobs.IndexService) JField(jadx.gui.treemodel.JField) Locale(java.util.Locale) ApkSignature(jadx.gui.treemodel.ApkSignature) CommentsIndex(jadx.gui.utils.search.CommentsIndex) MouseAdapter(java.awt.event.MouseAdapter) IssuesPanel(jadx.gui.ui.panel.IssuesPanel) HeadlessException(java.awt.HeadlessException) BorderLayout(java.awt.BorderLayout) JLoadableNode(jadx.gui.treemodel.JLoadableNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) JMenuBar(javax.swing.JMenuBar) Font(java.awt.Font) IUpdateCallback(jadx.gui.update.JadxUpdate.IUpdateCallback) JMenu(javax.swing.JMenu) LogCollector(jadx.gui.utils.logs.LogCollector) Collectors(java.util.stream.Collectors) WindowEvent(java.awt.event.WindowEvent) Theme(org.fife.ui.rsyntaxtextarea.Theme) MenuListener(javax.swing.event.MenuListener) Nullable(org.jetbrains.annotations.Nullable) RenameDialog(jadx.gui.ui.dialog.RenameDialog) Dimension(java.awt.Dimension) List(java.util.List) JadxArgs(jadx.api.JadxArgs) TextSearchIndex(jadx.gui.utils.search.TextSearchIndex) Toolkit(java.awt.Toolkit) Rectangle(java.awt.Rectangle) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) TreeNode(javax.swing.tree.TreeNode) ADBDialog(jadx.gui.ui.dialog.ADBDialog) GraphicsDevice(java.awt.GraphicsDevice) NLS(jadx.gui.utils.NLS) HashSet(java.util.HashSet) JPackagePopupMenu(jadx.gui.ui.popupmenu.JPackagePopupMenu) AWTEvent(java.awt.AWTEvent) FocusAdapter(java.awt.event.FocusAdapter) SwingUtilities(javax.swing.SwingUtilities) KeyStroke.getKeyStroke(javax.swing.KeyStroke.getKeyStroke) JMenuItem(javax.swing.JMenuItem) UiUtils(jadx.gui.utils.UiUtils) DisplayMode(java.awt.DisplayMode) BreakpointManager(jadx.gui.device.debugger.BreakpointManager) JNode(jadx.gui.treemodel.JNode) JClass(jadx.gui.treemodel.JClass) TreeWillExpandListener(javax.swing.event.TreeWillExpandListener) EditorViewState(jadx.gui.ui.codearea.EditorViewState) ExecutorService(java.util.concurrent.ExecutorService) ProcessResult(jadx.gui.jobs.ProcessResult) JPackage(jadx.gui.treemodel.JPackage) Logger(org.slf4j.Logger) DecompileTask(jadx.gui.jobs.DecompileTask) JPopupMenu(javax.swing.JPopupMenu) FileInputStream(java.io.FileInputStream) JOptionPane(javax.swing.JOptionPane) JTree(javax.swing.JTree) ActionEvent(java.awt.event.ActionEvent) JadxWrapper(jadx.gui.JadxWrapper) BackgroundExecutor(jadx.gui.jobs.BackgroundExecutor) Level(ch.qos.logback.classic.Level) JResource(jadx.gui.treemodel.JResource) FocusEvent(java.awt.event.FocusEvent) JRoot(jadx.gui.treemodel.JRoot) Collections(java.util.Collections) FileUtils.toPaths(jadx.gui.utils.FileUtils.toPaths) InputStream(java.io.InputStream) AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) AboutDialog(jadx.gui.ui.dialog.AboutDialog) QuarkDialog(jadx.gui.plugins.quark.QuarkDialog) ActionEvent(java.awt.event.ActionEvent) JadxSettingsWindow(jadx.gui.settings.JadxSettingsWindow) AbstractCodeContentPanel(jadx.gui.ui.codearea.AbstractCodeContentPanel) JToolBar(javax.swing.JToolBar) ADBDialog(jadx.gui.ui.dialog.ADBDialog) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) ContentPanel(jadx.gui.ui.panel.ContentPanel) AbstractCodeContentPanel(jadx.gui.ui.codearea.AbstractCodeContentPanel) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) AbstractCodeArea(jadx.gui.ui.codearea.AbstractCodeArea) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar) Link(jadx.gui.utils.Link)

Example 58 with JToolBar

use of javax.swing.JToolBar in project jadx by skylot.

the class JDebuggerPanel method initToolBar.

private JToolBar initToolBar() {
    AbstractAction stepOver = new AbstractAction(NLS.str("debugger.step_over"), ICON_STEP_OVER) {

        private static final long serialVersionUID = -1111111202103170726L;

        @Override
        public void actionPerformed(ActionEvent e) {
            controller.stepOver();
        }
    };
    stepOver.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.step_over"));
    AbstractAction stepInto = new AbstractAction(NLS.str("debugger.step_into"), ICON_STEP_INTO) {

        private static final long serialVersionUID = -1111111202103170727L;

        @Override
        public void actionPerformed(ActionEvent e) {
            controller.stepInto();
        }
    };
    stepInto.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.step_into"));
    AbstractAction stepOut = new AbstractAction(NLS.str("debugger.step_out"), ICON_STEP_OUT) {

        private static final long serialVersionUID = -1111111202103170728L;

        @Override
        public void actionPerformed(ActionEvent e) {
            controller.stepOut();
        }
    };
    stepOut.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.step_out"));
    AbstractAction stop = new AbstractAction(NLS.str("debugger.stop"), ICON_STOP_GRAY) {

        private static final long serialVersionUID = -1111111202103170728L;

        @Override
        public void actionPerformed(ActionEvent e) {
            controller.stop();
        }
    };
    stop.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.stop"));
    AbstractAction run = new AbstractAction(NLS.str("debugger.run"), ICON_RUN) {

        private static final long serialVersionUID = -1111111202103170728L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if (controller.isDebugging()) {
                if (controller.isSuspended()) {
                    controller.run();
                } else {
                    controller.pause();
                }
            }
        }
    };
    run.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.run"));
    AbstractAction rerun = new AbstractAction(NLS.str("debugger.rerun"), ICON_RERUN) {

        private static final long serialVersionUID = -1111111202103210433L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if (controller.isDebugging()) {
                controller.stop();
            }
            String pkgName = controller.getProcessName();
            if (pkgName.isEmpty() || !ADBDialog.launchForDebugging(mainWindow, pkgName, true)) {
                (new ADBDialog(mainWindow)).setVisible(true);
            }
        }
    };
    rerun.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.rerun"));
    controller.setStateListener(new DebugController.StateListener() {

        boolean isGray = true;

        @Override
        public void onStateChanged(boolean suspended, boolean stopped) {
            if (!stopped) {
                if (isGray) {
                    stop.putValue(Action.SMALL_ICON, ICON_STOP);
                }
            } else {
                stop.putValue(Action.SMALL_ICON, ICON_STOP_GRAY);
                run.putValue(Action.SMALL_ICON, ICON_RUN);
                run.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.run"));
                isGray = true;
                return;
            }
            if (suspended) {
                run.putValue(Action.SMALL_ICON, ICON_RUN);
                run.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.run"));
            } else {
                run.putValue(Action.SMALL_ICON, ICON_PAUSE);
                run.putValue(Action.SHORT_DESCRIPTION, NLS.str("debugger.pause"));
            }
        }
    });
    JToolBar toolBar = new JToolBar();
    toolBar.add(new Label());
    toolBar.add(Box.createHorizontalGlue());
    toolBar.add(rerun);
    toolBar.add(Box.createRigidArea(new Dimension(5, 0)));
    toolBar.add(stop);
    toolBar.add(Box.createRigidArea(new Dimension(5, 0)));
    toolBar.add(run);
    toolBar.add(Box.createRigidArea(new Dimension(5, 0)));
    toolBar.add(stepOver);
    toolBar.add(Box.createRigidArea(new Dimension(5, 0)));
    toolBar.add(stepInto);
    toolBar.add(Box.createRigidArea(new Dimension(5, 0)));
    toolBar.add(stepOut);
    toolBar.add(Box.createHorizontalGlue());
    toolBar.add(new Label());
    regShortcuts();
    return toolBar;
}
Also used : ActionEvent(java.awt.event.ActionEvent) Label(java.awt.Label) DebugController(jadx.gui.device.debugger.DebugController) JToolBar(javax.swing.JToolBar) Dimension(java.awt.Dimension) AbstractAction(javax.swing.AbstractAction) ADBDialog(jadx.gui.ui.dialog.ADBDialog)

Example 59 with JToolBar

use of javax.swing.JToolBar in project cayenne by apache.

the class EditorView method initView.

private void initView() {
    setBorder(BorderFactory.createEmptyBorder(1, 0, 0, 1));
    // init widgets
    actionManager.getAction(CollapseTreeAction.class).setAlwaysOn(true);
    actionManager.getAction(FilterAction.class).setAlwaysOn(true);
    actionManager.getAction(FilterAction.class).resetDialog();
    JToolBar barPanel = new JToolBar();
    barPanel.setFloatable(false);
    barPanel.setMinimumSize(new Dimension(75, 30));
    barPanel.setBorder(BorderFactory.createEmptyBorder());
    barPanel.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    JButton collapseButton = getAction(CollapseTreeAction.class).buildButton(1);
    JButton filterButton = getAction(FilterAction.class).buildButton(3);
    filterButton.setPreferredSize(new Dimension(30, 30));
    collapseButton.setPreferredSize(new Dimension(30, 30));
    barPanel.add(filterButton);
    barPanel.add(collapseButton);
    treePanel = new ProjectTreeView(eventController);
    treePanel.setMinimumSize(new Dimension(75, 180));
    JPanel treeNavigatePanel = new JPanel();
    treeNavigatePanel.setMinimumSize(new Dimension(75, 220));
    treeNavigatePanel.setLayout(new BorderLayout());
    treeNavigatePanel.add(treePanel, BorderLayout.CENTER);
    detailPanel = new JPanel();
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
    splitPane.setDividerSize(2);
    splitPane.setBorder(BorderFactory.createEmptyBorder());
    leftPanel = new JPanel(new BorderLayout());
    // assemble...
    detailLayout = new CardLayout();
    detailPanel.setLayout(detailLayout);
    // some but not all panels must be wrapped in a scroll pane
    // those that are not wrapped usually have there own scrollers
    // in subpanels...
    detailPanel.add(new JPanel(), EMPTY_VIEW);
    dataDomainView = new DataDomainTabbedView(eventController);
    detailPanel.add(dataDomainView, DOMAIN_VIEW);
    DataNodeEditor nodeController = new DataNodeEditor(eventController);
    detailPanel.add(nodeController.getView(), NODE_VIEW);
    dataNodeView = nodeController.getTabComponent();
    dataMapView = new DataMapTabbedView(eventController);
    detailPanel.add(dataMapView, DATA_MAP_VIEW);
    procedureView = new ProcedureTabbedView(eventController);
    detailPanel.add(procedureView, PROCEDURE_VIEW);
    selectQueryView = new SelectQueryTabbedView(eventController);
    detailPanel.add(selectQueryView, SELECT_QUERY_VIEW);
    sqlTemplateView = new SQLTemplateTabbedView(eventController);
    detailPanel.add(sqlTemplateView, SQL_TEMPLATE_VIEW);
    Component procedureQueryView = new ProcedureQueryView(eventController);
    detailPanel.add(new JScrollPane(procedureQueryView), PROCEDURE_QUERY_VIEW);
    ejbqlQueryView = new EjbqlTabbedView(eventController);
    detailPanel.add(ejbqlQueryView, EJBQL_QUERY_VIEW);
    embeddableView = new EmbeddableTabbedView(eventController);
    detailPanel.add(embeddableView, EMBEDDABLE_VIEW);
    objDetailView = new ObjEntityTabbedView(eventController);
    detailPanel.add(objDetailView, OBJ_VIEW);
    dbDetailView = new DbEntityTabbedView(eventController);
    detailPanel.add(dbDetailView, DB_VIEW);
    leftPanel.add(barPanel, BorderLayout.NORTH);
    leftPanel.setBorder(BorderFactory.createEmptyBorder());
    JScrollPane scrollPane = new JScrollPane(treeNavigatePanel);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    leftPanel.add(scrollPane, BorderLayout.CENTER);
    splitPane.setLeftComponent(leftPanel);
    splitPane.setRightComponent(detailPanel);
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) CardLayout(java.awt.CardLayout) DbEntityTabbedView(org.apache.cayenne.modeler.editor.dbentity.DbEntityTabbedView) CollapseTreeAction(org.apache.cayenne.modeler.action.CollapseTreeAction) DataNodeEditor(org.apache.cayenne.modeler.editor.datanode.DataNodeEditor) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar) Dimension(java.awt.Dimension) ProjectTreeView(org.apache.cayenne.modeler.ProjectTreeView) BorderLayout(java.awt.BorderLayout) JSplitPane(javax.swing.JSplitPane) Component(java.awt.Component) FilterAction(org.apache.cayenne.modeler.action.FilterAction)

Example 60 with JToolBar

use of javax.swing.JToolBar in project cayenne by apache.

the class EmbeddableAttributeTab method init.

private void init() {
    this.setLayout(new BorderLayout());
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    ActionManager actionManager = Application.getInstance().getActionManager();
    toolBar.add(actionManager.getAction(CreateAttributeAction.class).buildButton());
    toolBar.addSeparator();
    toolBar.add(actionManager.getAction(RemoveAttributeAction.class).buildButton());
    toolBar.addSeparator();
    toolBar.add(actionManager.getAction(CutAttributeAction.class).buildButton(1));
    toolBar.add(actionManager.getAction(CopyAttributeAction.class).buildButton(2));
    toolBar.add(actionManager.getAction(PasteAction.class).buildButton(3));
    add(toolBar, BorderLayout.NORTH);
    table = new CayenneTable();
    tablePreferences = new TableColumnPreferences(this.getClass(), "embeddable/attributeTable");
    // Create and install a popup
    JPopupMenu popup = new JPopupMenu();
    popup.add(actionManager.getAction(RemoveAttributeAction.class).buildMenu());
    popup.addSeparator();
    popup.add(actionManager.getAction(CutAttributeAction.class).buildMenu());
    popup.add(actionManager.getAction(CopyAttributeAction.class).buildMenu());
    popup.add(actionManager.getAction(PasteAction.class).buildMenu());
    TablePopupHandler.install(table, popup);
    add(PanelFactory.createTablePanel(table, null), BorderLayout.CENTER);
}
Also used : ActionManager(org.apache.cayenne.modeler.action.ActionManager) CayenneTable(org.apache.cayenne.modeler.util.CayenneTable) BorderLayout(java.awt.BorderLayout) JToolBar(javax.swing.JToolBar) TableColumnPreferences(org.apache.cayenne.modeler.pref.TableColumnPreferences) JPopupMenu(javax.swing.JPopupMenu)

Aggregations

JToolBar (javax.swing.JToolBar)124 JButton (javax.swing.JButton)51 BorderLayout (java.awt.BorderLayout)45 JPanel (javax.swing.JPanel)37 JScrollPane (javax.swing.JScrollPane)30 Dimension (java.awt.Dimension)25 Insets (java.awt.Insets)25 ActionEvent (java.awt.event.ActionEvent)24 JLabel (javax.swing.JLabel)23 ActionListener (java.awt.event.ActionListener)19 ImageIcon (javax.swing.ImageIcon)17 Component (java.awt.Component)14 JSplitPane (javax.swing.JSplitPane)14 JTable (javax.swing.JTable)14 JTextField (javax.swing.JTextField)14 JPopupMenu (javax.swing.JPopupMenu)13 JToggleButton (javax.swing.JToggleButton)12 GridBagConstraints (java.awt.GridBagConstraints)10 GridBagLayout (java.awt.GridBagLayout)10 JComponent (javax.swing.JComponent)10