Search in sources :

Example 31 with JComponent

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

the class ExtensionHelp method setHelpEnabled.

/**
	 * Sets whether or not the help is enabled (menu item, buttons and help for the components).
	 * <p>
	 * The call to this method has no effect if the view is not initialised.
	 * 
	 * @param enabled {@code true} if the help should be enabled, {@code false} otherwise
	 * @see #findHelpSetUrl()
	 */
private void setHelpEnabled(boolean enabled) {
    if (getView() == null) {
        return;
    }
    JRootPane rootPane = getView().getMainFrame().getRootPane();
    if (enabled && findHelpSetUrl() != null) {
        createHelpBroker();
        getMenuHelpZapUserGuide().addActionListener(showHelpActionListener);
        getMenuHelpZapUserGuide().setToolTipText(null);
        getMenuHelpZapUserGuide().setEnabled(true);
        // Enable the top level F1 help key
        hb.enableHelpKey(rootPane, "zap.intro", hs, "javax.help.SecondaryWindow", null);
        for (Entry<JComponent, String> entry : componentsWithHelp.entrySet()) {
            hb.enableHelp(entry.getKey(), entry.getValue(), hs);
        }
        getHelpButton().setToolTipText(Constant.messages.getString("help.button.tooltip"));
        getHelpButton().setEnabled(true);
    } else {
        String toolTipNoHelp = Constant.messages.getString("help.error.nohelp");
        getMenuHelpZapUserGuide().setEnabled(false);
        getMenuHelpZapUserGuide().setToolTipText(toolTipNoHelp);
        getMenuHelpZapUserGuide().removeActionListener(showHelpActionListener);
        rootPane.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0));
        rootPane.unregisterKeyboardAction(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
        removeHelpProperties(rootPane);
        for (JComponent component : componentsWithHelp.keySet()) {
            removeHelpProperties(component);
        }
        getHelpButton().setEnabled(false);
        getHelpButton().setToolTipText(toolTipNoHelp);
        hb = null;
        hs = null;
        showHelpActionListener = null;
    }
}
Also used : JComponent(javax.swing.JComponent) JRootPane(javax.swing.JRootPane)

Example 32 with JComponent

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

the class ExtensionHelp method enableHelpKey.

/**
	 * Enables the help for the given component using the given help page ID.
	 * <p>
	 * The help page is shown when the help keyboard shortcut (F1) is pressed, while the component is focused.
	 *
	 * @param component the component that will have a help page assigned
	 * @param id the ID of the help page
	 */
public static void enableHelpKey(Component component, String id) {
    if (component instanceof JComponent) {
        JComponent jComponent = (JComponent) component;
        if (componentsWithHelp == null) {
            componentsWithHelp = new WeakHashMap<>();
        }
        componentsWithHelp.put(jComponent, id);
    }
    if (hb != null) {
        hb.enableHelp(component, id, hs);
    }
}
Also used : JComponent(javax.swing.JComponent)

Example 33 with JComponent

use of javax.swing.JComponent in project enclojure by EricThorsen.

the class ClojureBreakpointActionsProvider method customize.

private static void customize(Breakpoint b) {
    JComponent c = null;
    if (b instanceof ClojureLineBreakpoint) {
        c = new ClojureBreakpointPanel((ClojureLineBreakpoint) b);
    }
    DialogDescriptor descriptor = new DialogDescriptor(c, NbBundle.getMessage(ClojureBreakpointActionsProvider.class, "CTL_Breakpoint_Customizer_Title"));
    JButton bOk = null;
    JButton bClose = null;
    descriptor.setOptions(new JButton[] { bOk = new JButton(NbBundle.getMessage(ClojureBreakpointActionsProvider.class, "CTL_Ok")), bClose = new JButton(NbBundle.getMessage(ClojureBreakpointActionsProvider.class, "CTL_Close")) });
    HelpCtx helpCtx = HelpCtx.findHelp(c);
    if (helpCtx == null)
        helpCtx = new HelpCtx("debug.add.breakpoint");
    ;
    descriptor.setHelpCtx(helpCtx);
    bOk.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ClojureBreakpointActionsProvider.class, "ACSD_CTL_Ok"));
    bOk.setMnemonic(NbBundle.getMessage(ClojureBreakpointActionsProvider.class, "CTL_Ok_MNEM").charAt(0));
    bClose.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ClojureBreakpointActionsProvider.class, "ACSD_CTL_Close"));
    bClose.setMnemonic(NbBundle.getMessage(ClojureBreakpointActionsProvider.class, "CTL_Close_MNEM").charAt(0));
    descriptor.setClosingOptions(null);
    Dialog d = DialogDisplayer.getDefault().createDialog(descriptor);
    d.pack();
    d.setVisible(true);
    if (descriptor.getValue() == bOk) {
        ((Controller) c).ok();
    }
}
Also used : Dialog(java.awt.Dialog) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton)

Example 34 with JComponent

use of javax.swing.JComponent in project enclojure by EricThorsen.

the class ClojureTemplateWizardIterator method initialize.

public void initialize(WizardDescriptor wiz) {
    this.wiz = wiz;
    index = 0;
    panels = createPanels();
    // Make sure list of steps is accurate.
    String[] steps = createSteps();
    for (int i = 0; i < panels.length; i++) {
        Component c = panels[i].getComponent();
        if (steps[i] == null) {
            // Default step name to component name of panel.
            // Mainly useful for getting the name of the target
            // chooser to appear in the list of steps.
            steps[i] = c.getName();
        }
        if (c instanceof JComponent) {
            // assume Swing components
            JComponent jc = (JComponent) c;
            // Step #.
            jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
            // Step name (actually the whole list for reference).
            jc.putClientProperty("WizardPanel_contentData", steps);
        }
    }
}
Also used : JComponent(javax.swing.JComponent) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Example 35 with JComponent

use of javax.swing.JComponent in project otapij by FellowTraveler.

the class CustomTable method prepareRenderer.

public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
    Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
    if (c instanceof JComponent) {
        JComponent jc = (JComponent) c;
        if (getValueAt(rowIndex, vColIndex) instanceof String) {
            //Utility.getKeyFromName((String)getValueAt(rowIndex, vColIndex));
            String value = (String) getValueAt(rowIndex, vColIndex);
            if (this.getModel() instanceof AccountTableModel && vColIndex == 0) {
                value = (String) this.getModel().getValueAt(rowIndex, 3);
            }
            if (this.getModel() instanceof NYMTableModel && vColIndex == 0) {
                value = (String) this.getModel().getValueAt(rowIndex, 1);
            }
            if (this.getModel() instanceof BasketTableModel && vColIndex == 0) {
                value = (String) this.getModel().getValueAt(rowIndex, 1);
            }
            if (this.getModel() instanceof AssetContractTableModel && vColIndex == 0) {
                value = (String) this.getModel().getValueAt(rowIndex, 1);
            }
            if (this.getModel() instanceof ServerContractTableModel && vColIndex == 0) {
                value = (String) this.getModel().getValueAt(rowIndex, 1);
            }
            if (this.getModel() instanceof OTOutboxTableModel) {
                if (vColIndex == 4)
                    value = (String) this.getModel().getValueAt(rowIndex, 8);
                if (vColIndex == 5)
                    value = (String) this.getModel().getValueAt(rowIndex, 9);
            }
            if (this.getModel() instanceof OTInboxTableModel) {
                if (vColIndex == 4)
                    value = (String) this.getModel().getValueAt(rowIndex, 10);
                if (vColIndex == 5)
                    value = (String) this.getModel().getValueAt(rowIndex, 11);
            }
            if (this.getModel() instanceof NYMOutboxTableModel) {
                if (vColIndex == 1)
                    value = (String) this.getModel().getValueAt(rowIndex, 4);
                if (vColIndex == 2)
                    value = (String) this.getModel().getValueAt(rowIndex, 5);
            }
            if (this.getModel() instanceof NYMBoxTableModel) {
                if (vColIndex == 1)
                    value = (String) this.getModel().getValueAt(rowIndex, 4);
                if (vColIndex == 2)
                    value = (String) this.getModel().getValueAt(rowIndex, 5);
            }
            jc.setToolTipText(value);
        }
    }
    return c;
}
Also used : BasketTableModel(com.moneychanger.ui.model.BasketTableModel) NYMTableModel(com.moneychanger.ui.model.NYMTableModel) OTInboxTableModel(com.moneychanger.ui.model.OTInboxTableModel) NYMBoxTableModel(com.moneychanger.ui.model.NYMBoxTableModel) AccountTableModel(com.moneychanger.ui.model.AccountTableModel) NYMOutboxTableModel(com.moneychanger.ui.model.NYMOutboxTableModel) JComponent(javax.swing.JComponent) OTOutboxTableModel(com.moneychanger.ui.model.OTOutboxTableModel) JComponent(javax.swing.JComponent) Component(java.awt.Component) ServerContractTableModel(com.moneychanger.ui.model.ServerContractTableModel) AssetContractTableModel(com.moneychanger.ui.model.AssetContractTableModel)

Aggregations

JComponent (javax.swing.JComponent)225 Component (java.awt.Component)44 JPanel (javax.swing.JPanel)37 JLabel (javax.swing.JLabel)34 JButton (javax.swing.JButton)28 BorderLayout (java.awt.BorderLayout)27 Dimension (java.awt.Dimension)23 Insets (java.awt.Insets)20 ActionEvent (java.awt.event.ActionEvent)16 ArrayList (java.util.ArrayList)16 ActionListener (java.awt.event.ActionListener)15 Color (java.awt.Color)13 GridBagConstraints (java.awt.GridBagConstraints)13 Point (java.awt.Point)13 GridBagLayout (java.awt.GridBagLayout)12 JScrollPane (javax.swing.JScrollPane)12 JTextField (javax.swing.JTextField)12 JFrame (javax.swing.JFrame)11 Container (java.awt.Container)8 FlowLayout (java.awt.FlowLayout)8