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;
}
}
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);
}
}
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();
}
}
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);
}
}
}
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;
}
Aggregations