Search in sources :

Example 1 with Printable

use of org.apache.jmeter.visualizers.Printable in project jmeter by apache.

the class MenuFactory method addFileMenu.

/**
     * @param menu JPopupMenu
     * @param addSaveTestFragmentMenu Add Save as Test Fragment menu if true 
     */
public static void addFileMenu(JPopupMenu menu, boolean addSaveTestFragmentMenu) {
    // maybe there's better place for them in JMeter?
    if (UndoHistory.isEnabled()) {
        addUndoItems(menu);
    }
    addSeparator(menu);
    // $NON-NLS-1$
    menu.add(makeMenuItemRes("open", ActionNames.OPEN));
    // $NON-NLS-1$
    menu.add(makeMenuItemRes("menu_merge", ActionNames.MERGE));
    // $NON-NLS-1$
    menu.add(makeMenuItemRes("save_as", ActionNames.SAVE_AS));
    if (addSaveTestFragmentMenu) {
        // $NON-NLS-1$
        menu.add(makeMenuItemRes("save_as_test_fragment", ActionNames.SAVE_AS_TEST_FRAGMENT));
    }
    addSeparator(menu);
    JMenuItem savePicture = makeMenuItemRes(// $NON-NLS-1$
    "save_as_image", ActionNames.SAVE_GRAPHICS, KeyStrokes.SAVE_GRAPHICS);
    menu.add(savePicture);
    if (!(GuiPackage.getInstance().getCurrentGui() instanceof Printable)) {
        savePicture.setEnabled(false);
    }
    JMenuItem savePictureAll = makeMenuItemRes(// $NON-NLS-1$
    "save_as_image_all", ActionNames.SAVE_GRAPHICS_ALL, KeyStrokes.SAVE_GRAPHICS_ALL);
    menu.add(savePictureAll);
    addSeparator(menu);
    // $NON-NLS-1$
    JMenuItem disabled = makeMenuItemRes("disable", ActionNames.DISABLE);
    // $NON-NLS-1$
    JMenuItem enabled = makeMenuItemRes("enable", ActionNames.ENABLE);
    boolean isEnabled = GuiPackage.getInstance().getTreeListener().getCurrentNode().isEnabled();
    if (isEnabled) {
        disabled.setEnabled(true);
        enabled.setEnabled(false);
    } else {
        disabled.setEnabled(false);
        enabled.setEnabled(true);
    }
    menu.add(enabled);
    menu.add(disabled);
    // $NON-NLS-1$
    JMenuItem toggle = makeMenuItemRes("toggle", ActionNames.TOGGLE, KeyStrokes.TOGGLE);
    menu.add(toggle);
    addSeparator(menu);
    // $NON-NLS-1$
    menu.add(makeMenuItemRes("help", ActionNames.HELP));
}
Also used : Printable(org.apache.jmeter.visualizers.Printable) JMenuItem(javax.swing.JMenuItem)

Example 2 with Printable

use of org.apache.jmeter.visualizers.Printable in project jmeter by apache.

the class SaveGraphics method doAction.

@Override
public void doAction(ActionEvent e) throws IllegalUserActionException {
    if (!commands.contains(e.getActionCommand())) {
        throw new IllegalUserActionException("Invalid user command:" + e.getActionCommand());
    }
    if (e.getActionCommand().equals(ActionNames.SAVE_GRAPHICS)) {
        JMeterGUIComponent component = GuiPackage.getInstance().getCurrentGui();
        // get the JComponent from the visualizer
        if (component instanceof Printable) {
            JComponent comp = ((Printable) component).getPrintableComponent();
            saveImage(comp);
        }
    }
    if (e.getActionCommand().equals(ActionNames.SAVE_GRAPHICS_ALL)) {
        JMeterGUIComponent component = GuiPackage.getInstance().getCurrentGui();
        JComponent comp = ((JComponent) component).getRootPane();
        saveImage(comp);
    }
}
Also used : JComponent(javax.swing.JComponent) IllegalUserActionException(org.apache.jmeter.exceptions.IllegalUserActionException) JMeterGUIComponent(org.apache.jmeter.gui.JMeterGUIComponent) Printable(org.apache.jmeter.visualizers.Printable)

Aggregations

Printable (org.apache.jmeter.visualizers.Printable)2 JComponent (javax.swing.JComponent)1 JMenuItem (javax.swing.JMenuItem)1 IllegalUserActionException (org.apache.jmeter.exceptions.IllegalUserActionException)1 JMeterGUIComponent (org.apache.jmeter.gui.JMeterGUIComponent)1