use of javax.help.DefaultHelpBroker in project keystore-explorer by kaikramer.
the class HelpAction method createAndDisplayHelp.
private void createAndDisplayHelp() throws HelpSetException {
URL hsUrl = getClass().getResource(res.getString("HelpAction.HelpSet"));
HelpSet hs = new HelpSet(getClass().getClassLoader(), hsUrl);
if (LnfUtil.isDarculaAvailable()) {
URL hsDarculaUrl = getClass().getResource(res.getString("HelpAction.DarculaHelpSet"));
HelpSet hsDarcula = new HelpSet(getClass().getClassLoader(), hsDarculaUrl);
hs.add(hsDarcula);
}
helpBroker = new DefaultHelpBroker(hs);
WindowPresentation windowPresentation = helpBroker.getWindowPresentation();
windowPresentation.createHelpWindow();
// Make window immune to modal dialogs in application
Window helpWindow = windowPresentation.getHelpWindow();
helpWindow.setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
// Set help icons - set lots of different sizes to give each OS the most
// flexibility in choosing an icon for display
ArrayList<Image> icons = new ArrayList<Image>();
icons.add(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("HelpAction.image.16x16"))));
icons.add(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("HelpAction.image.24x24"))));
icons.add(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("HelpAction.image.32x32"))));
helpWindow.setIconImages(icons);
helpBroker.setLocation(new Point(frame.getX() + 25, frame.getY() + 25));
helpBroker.setSize(new Dimension(850, 600));
helpBroker.setCurrentID(START_ID);
helpBroker.setDisplayed(true);
}
use of javax.help.DefaultHelpBroker in project edumips64 by lupino3.
the class GUIHelp method showHelp.
/**
* Shows the EduMIPS64 help window.
*
* @param parent the window that owns this help dialog
* @param helpSetUrl the URL to the directory of the help set.
*/
public static void showHelp(Window parent, URL helpSetUrl, ConfigStore cfg) throws HelpSetException, BadIDException, MalformedURLException {
// Clean up the URL from spaces.
String cleanUrl = helpSetUrl.getProtocol() + ":" + helpSetUrl.getPath().replace("%20", " ");
URL[] aurl = GUIHelp.parseURLs(cleanUrl);
URLClassLoader urlclassloader = new URLClassLoader(aurl);
URL url = HelpSet.findHelpSet(urlclassloader, HELPSET);
int desiredFontSize = cfg.getInt(ConfigKey.UI_FONT_SIZE);
float windowScalingFactor = desiredFontSize / 12.0f;
HelpSet helpset = new HelpSet(urlclassloader, url);
HelpBroker helpBroker = helpset.createHelpBroker();
helpBroker.initPresentation();
helpBroker.setSize(new Dimension((int) (800 * windowScalingFactor), (int) (600 * windowScalingFactor)));
// Update the font.
helpBroker.setSize(helpBroker.getSize());
Font newFont = helpBroker.getFont().deriveFont((float) desiredFontSize);
((DefaultHelpBroker) helpBroker).setActivationWindow(parent);
helpBroker.initPresentation();
helpBroker.setFont(newFont);
helpBroker.setDisplayed(true);
}
use of javax.help.DefaultHelpBroker in project bundle-app-ui by astrapi69.
the class DesktopMenu method newHelpMenu.
/**
* Factory method for create new {@link JMenu} for the help menu.
*
* @param listener
* the listener
* @return the j menu
*/
private JMenu newHelpMenu(final ActionListener listener) {
// Help menu
// $NON-NLS-1$
final JMenu menuHelp = new JMenu("Help");
menuHelp.setMnemonic('H');
// Help JMenuItems
// Help content
// $NON-NLS-1$
final JMenuItem mihHelpContent = new JMenuItem("Content", 'c');
MenuExtensions.setCtrlAccelerator(mihHelpContent, 'H');
menuHelp.add(mihHelpContent);
// found bug with the javax.help
// Exception in thread "main" java.lang.SecurityException: no manifiest
// section for signature file entry
// com/sun/java/help/impl/TagProperties.class
// Solution is to remove the rsa files from the jar
final HelpSet hs = getHelpSet();
final DefaultHelpBroker helpBroker = (DefaultHelpBroker) hs.createHelpBroker();
final WindowPresentation pres = helpBroker.getWindowPresentation();
pres.createHelpWindow();
helpWindow = pres.getHelpWindow();
helpWindow.setLocationRelativeTo(null);
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (final Exception e1) {
log.error(e1.getLocalizedMessage(), e1);
}
SwingUtilities.updateComponentTreeUI(helpWindow);
// 2. assign help to components
CSH.setHelpIDString(mihHelpContent, "Overview");
// 3. handle events
final CSH.DisplayHelpFromSource displayHelpFromSource = new CSH.DisplayHelpFromSource(helpBroker);
mihHelpContent.addActionListener(displayHelpFromSource);
mihHelpContent.addActionListener(new ShowHelpDialogAction("Content"));
// Donate
final JMenuItem mihDonate = new JMenuItem(// $NON-NLS-1$
Messages.getString("com.find.duplicate.files.menu.item.donate"));
mihDonate.addActionListener(new OpenBrowserToDonateAction("Donate"));
menuHelp.add(mihDonate);
// Licence
// $NON-NLS-1$
final JMenuItem mihLicence = new JMenuItem("Licence");
mihLicence.addActionListener(new ShowLicenseFrameAction("Licence"));
menuHelp.add(mihLicence);
// Info
// $NON-NLS-1$
final JMenuItem mihInfo = new JMenuItem("Info", 'i');
MenuExtensions.setCtrlAccelerator(mihInfo, 'I');
mihInfo.addActionListener(new ShowInfoDialogAction("Info"));
menuHelp.add(mihInfo);
return menuHelp;
}
Aggregations