# HG changeset patch # Parent 6d4605b4b0c394a15a556f0f74cb2d7b16d56d59 # User Jesse Glick #205992: SPI to show a HelpCtx. diff --git a/autoupdate.ui/nbproject/project.xml b/autoupdate.ui/nbproject/project.xml --- a/autoupdate.ui/nbproject/project.xml +++ b/autoupdate.ui/nbproject/project.xml @@ -68,7 +68,7 @@ - 8.12 + 8.21 diff --git a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/PluginManagerUI.java b/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/PluginManagerUI.java --- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/PluginManagerUI.java +++ b/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/PluginManagerUI.java @@ -47,25 +47,12 @@ import java.awt.Component; import java.awt.Cursor; import java.awt.Window; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.awt.dnd.DnDConstants; import java.awt.dnd.DropTarget; -import java.awt.dnd.DropTargetDragEvent; -import java.awt.dnd.DropTargetDropEvent; -import java.awt.dnd.DropTargetEvent; import java.awt.dnd.DropTargetListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.io.File; -import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URI; import java.util.*; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.DropMode; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; @@ -80,9 +67,7 @@ import org.openide.NotifyDescriptor; import org.openide.util.Exceptions; import org.openide.util.HelpCtx; -import org.openide.util.Lookup; import org.openide.util.NbBundle; -import org.openide.util.NbCollections; import org.openide.util.RequestProcessor; /** @@ -177,7 +162,6 @@ // the Close & Help buttons are always enabled bClose.setEnabled (true); - bHelp.setEnabled (getHelpInstance () != null); Component parent = getParent (); Component rootPane = getRootPane (); @@ -467,58 +451,9 @@ }//GEN-LAST:event_tpTabsStateChanged private void bHelpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bHelpActionPerformed - try { - Object help = getHelpInstance (); - if (help == null) { - return; - } - Method showHelpM = help.getClass ().getMethod ("showHelp", HelpCtx.class); // NOI18N - if (showHelpM != null) { - showHelpM.invoke (help, getHelpCtx ()); - } - } catch (Exception ex) { - Logger.getLogger (PluginManagerUI.class.getName ()).log (Level.INFO, ex.getLocalizedMessage (), ex); - } + getHelpCtx().display(); }//GEN-LAST:event_bHelpActionPerformed - private Object getHelpInstance () { - if (helpInstance == null) { - try { - Class clazz = Class.forName("org.netbeans.api.javahelp.Help", // NOI18N - false, Thread.currentThread().getContextClassLoader()); - if (clazz == null) { - return null; - } - helpInstance = Lookup.getDefault ().lookup (clazz); - } catch (ClassNotFoundException ex) { - Logger.getLogger(PluginManagerUI.class.getName()).log(Level.FINE, "JavaHelp integration not found", ex); - } - } - return helpInstance; - } - - private boolean isValidHelpID (String id) { - boolean res = true; - try { - Object help = getHelpInstance (); - if (help == null) { - return res; - } - Method isValidIDM = help.getClass ().getMethod ("isValidID", String.class, boolean.class); // NOI18N - if (isValidIDM != null) { - Object resO = isValidIDM.invoke (help, id, true); - if (resO instanceof Boolean) { - res = (Boolean) resO; - } else { - res = true; - } - } - } catch (Exception ex) { - Logger.getLogger (PluginManagerUI.class.getName ()).log (Level.INFO, ex.getLocalizedMessage (), ex); - } - return res; - } - private HelpCtx getHelpCtx() { String id = PluginManagerUI.class.getName (); Component c = tpTabs.getSelectedComponent (); @@ -527,12 +462,6 @@ } else if (c instanceof SettingsTab) { id = SettingsTab.class.getName (); } - - Logger LOG = Logger.getLogger(PluginManagerUI.class.getName()); - if(LOG.isLoggable(Level.FINE)) { // #176576 - LOG.log(Level.FINE, - isValidHelpID(id) ? "HelpId is {0}" : "{0} looks no valid HelpCtx", id); - } return new HelpCtx (id); } @@ -561,7 +490,6 @@ SettingsTab tab = new SettingsTab (this); tpTabs.add (tab, INDEX_OF_SETTINGS_TAB); tpTabs.setTitleAt(INDEX_OF_SETTINGS_TAB, tab.getDisplayName()); - bHelp.setEnabled (getHelpInstance () != null); } void decorateTabTitle (UnitTable table) { diff --git a/cnd.debugger.common2/nbproject/project.xml b/cnd.debugger.common2/nbproject/project.xml --- a/cnd.debugger.common2/nbproject/project.xml +++ b/cnd.debugger.common2/nbproject/project.xml @@ -136,15 +136,6 @@ - org.netbeans.modules.javahelp - - - - 1 - 2.11.1 - - - org.netbeans.modules.options.api @@ -299,7 +290,7 @@ - 7.25.0.1 + 8.21 diff --git a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/utils/masterdetail/MasterDetailView.java b/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/utils/masterdetail/MasterDetailView.java --- a/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/utils/masterdetail/MasterDetailView.java +++ b/cnd.debugger.common2/src/org/netbeans/modules/cnd/debugger/common2/utils/masterdetail/MasterDetailView.java @@ -57,9 +57,6 @@ import org.openide.windows.TopComponent; import org.openide.util.HelpCtx; -import org.openide.util.Lookup; - -import org.netbeans.api.javahelp.Help; /** @@ -331,9 +328,10 @@ } private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) { - Help help = Lookup.getDefault().lookup(Help.class); - help.showHelp(getHelpCtx()); - + HelpCtx help = getHelpCtx(); + if (help != null) { + help.display(); + } } private void okButtonActionPerformed(java.awt.event.ActionEvent evt) { diff --git a/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java b/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java --- a/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java +++ b/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java @@ -111,7 +111,6 @@ import org.openide.util.ChangeSupport; import org.openide.util.HelpCtx; import org.openide.util.ImageUtilities; -import org.openide.util.Lookup; import org.openide.util.Mutex; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; @@ -1493,27 +1492,12 @@ } // end of HackTypeAhead /** Shows a specified HelpCtx in IDE's help window. - * XXX would be better to directly depend on org.netbeans.api.javahelp.Help * @param helpCtx thehelp to be shown */ private static void showHelp(HelpCtx helpCtx) { - // Awkward but should work. - try { - Class c = Lookup.getDefault().lookup(ClassLoader.class).loadClass("org.netbeans.api.javahelp.Help"); // NOI18N - Object o = Lookup.getDefault().lookup(c); - if (o != null) { - Method m = c.getMethod("showHelp", new Class[] {HelpCtx.class}); // NOI18N - m.invoke(o, new Object[] {helpCtx}); - return; - } - } catch (ClassNotFoundException cnfe) { - // ignore - maybe javahelp module is not installed, not so strange - } catch (Exception e) { - // potentially more serious - Logger.getLogger(NbPresenter.class.getName()).log(Level.WARNING, null, e); + if (!helpCtx.display()) { + Toolkit.getDefaultToolkit().beep(); } - // Did not work. - Toolkit.getDefaultToolkit().beep(); } } diff --git a/diff/nbproject/project.xml b/diff/nbproject/project.xml --- a/diff/nbproject/project.xml +++ b/diff/nbproject/project.xml @@ -119,15 +119,6 @@ - org.netbeans.modules.javahelp - - - - 1 - 2.7 - - - org.netbeans.modules.options.api @@ -238,7 +229,7 @@ - 8.0 + 8.21 diff --git a/diff/src/org/netbeans/modules/merge/builtin/visualizer/MergeDialogComponent.java b/diff/src/org/netbeans/modules/merge/builtin/visualizer/MergeDialogComponent.java --- a/diff/src/org/netbeans/modules/merge/builtin/visualizer/MergeDialogComponent.java +++ b/diff/src/org/netbeans/modules/merge/builtin/visualizer/MergeDialogComponent.java @@ -57,7 +57,6 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import javax.swing.JPopupMenu; import javax.swing.SwingUtilities; @@ -79,7 +78,6 @@ import org.openide.util.actions.CallableSystemAction; import org.openide.util.actions.SystemAction; import org.openide.windows.WindowManager; -import org.netbeans.api.javahelp.Help; /** * This is a component, that acts as a non modal dialog. @@ -285,8 +283,7 @@ }//GEN-LAST:event_okButtonActionPerformed private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpButtonActionPerformed - Help help = (Help) Lookup.getDefault().lookup(Help.class); - help.showHelp(getHelpCtx()); + getHelpCtx().display(); }//GEN-LAST:event_helpButtonActionPerformed private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed diff --git a/i18n/nbproject/project.xml b/i18n/nbproject/project.xml --- a/i18n/nbproject/project.xml +++ b/i18n/nbproject/project.xml @@ -92,15 +92,6 @@ - org.netbeans.modules.javahelp - - - - 1 - 1.2 - - - org.netbeans.modules.projectapi @@ -184,7 +175,7 @@ - 8.0 + 8.21 diff --git a/i18n/src/org/netbeans/modules/i18n/I18nPanel.java b/i18n/src/org/netbeans/modules/i18n/I18nPanel.java --- a/i18n/src/org/netbeans/modules/i18n/I18nPanel.java +++ b/i18n/src/org/netbeans/modules/i18n/I18nPanel.java @@ -48,7 +48,6 @@ import javax.swing.GroupLayout; import java.awt.CardLayout; -import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; @@ -66,8 +65,6 @@ import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; import org.openide.util.HelpCtx; -import org.openide.util.Lookup; -import org.netbeans.api.javahelp.Help; import org.netbeans.api.project.Project; import org.openide.awt.Mnemonics; import org.openide.util.Enumerations; @@ -490,8 +487,7 @@ if ("true".equals(sysprop) || "full".equals(sysprop)) { // NOI18N System.err.println ("I18n module: Help button showing: " + help); // NOI18N, please do not comment out } - Help helpSystem = Lookup.getDefault().lookup(Help.class); - helpSystem.showHelp(help); + help.display(); } private void enableButtons(long buttonMask) { diff --git a/identity.server.manager/nbproject/project.xml b/identity.server.manager/nbproject/project.xml --- a/identity.server.manager/nbproject/project.xml +++ b/identity.server.manager/nbproject/project.xml @@ -14,15 +14,6 @@ - org.netbeans.modules.javahelp - - - - 1 - 2.12 - - - org.openide.awt @@ -75,7 +66,7 @@ - 8.0 + 8.21 diff --git a/identity.server.manager/src/org/netbeans/modules/identity/server/manager/ui/actions/InfoAction.java b/identity.server.manager/src/org/netbeans/modules/identity/server/manager/ui/actions/InfoAction.java --- a/identity.server.manager/src/org/netbeans/modules/identity/server/manager/ui/actions/InfoAction.java +++ b/identity.server.manager/src/org/netbeans/modules/identity/server/manager/ui/actions/InfoAction.java @@ -42,21 +42,13 @@ package org.netbeans.modules.identity.server.manager.ui.actions; -import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import org.netbeans.api.javahelp.Help; import org.openide.util.HelpCtx; -import org.openide.util.Lookup; public final class InfoAction implements ActionListener { public void actionPerformed(ActionEvent e) { - Help h = (Help)Lookup.getDefault().lookup(Help.class); - if (h == null) { - Toolkit.getDefaultToolkit().beep(); - return; - } HelpCtx ctx = new HelpCtx("idmtools_am_ww_am_instances"); //NOI18N - h.showHelp(ctx); + ctx.display(); } } diff --git a/j2ee.sun.appsrv81/nbproject/project.xml b/j2ee.sun.appsrv81/nbproject/project.xml --- a/j2ee.sun.appsrv81/nbproject/project.xml +++ b/j2ee.sun.appsrv81/nbproject/project.xml @@ -195,12 +195,11 @@ - org.netbeans.modules.javahelp + org.netbeans.modules.keyring - 1 - 2.12 + 1.0 @@ -330,7 +329,7 @@ - 8.0 + 8.21 @@ -349,14 +348,6 @@ 6.2 - - org.netbeans.modules.keyring - - - - 1.0 - - diff --git a/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/InfoAction.java b/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/InfoAction.java --- a/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/InfoAction.java +++ b/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/InfoAction.java @@ -42,24 +42,16 @@ package org.netbeans.modules.j2ee.sun.ide; -import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import org.netbeans.api.javahelp.Help; import org.openide.util.HelpCtx; -import org.openide.util.Lookup; public final class InfoAction implements ActionListener { public void actionPerformed(ActionEvent e) { if ("noui".equals(e.getActionCommand())) { // NOI18N return; } - Help h = (Help)Lookup.getDefault().lookup(Help.class); - if (h == null) { - Toolkit.getDefaultToolkit().beep(); - return; - } HelpCtx ctx = new HelpCtx("register_appserver"); //NOI18N - h.showHelp(ctx); + ctx.display(); } } diff --git a/j2ee.sun.ddui/nbproject/project.xml b/j2ee.sun.ddui/nbproject/project.xml --- a/j2ee.sun.ddui/nbproject/project.xml +++ b/j2ee.sun.ddui/nbproject/project.xml @@ -197,15 +197,6 @@ - org.netbeans.modules.javahelp - - - - 1 - 1.0 - - - org.netbeans.modules.projectapi @@ -330,7 +321,7 @@ - 8.0 + 8.21 diff --git a/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/Utils.java b/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/Utils.java --- a/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/Utils.java +++ b/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/Utils.java @@ -49,8 +49,6 @@ import java.net.URLEncoder; import javax.swing.SwingUtilities; import org.openide.util.HelpCtx; -import org.openide.util.Lookup; -import org.netbeans.api.javahelp.Help; import org.openide.ErrorManager; @@ -316,7 +314,7 @@ public static void invokeHelp(final HelpCtx helpCtx) { SwingUtilities.invokeLater(new Runnable() { public void run() { - Lookup.getDefault().lookup(Help.class).showHelp(helpCtx); + helpCtx.display(); } }); } diff --git a/javadoc/nbproject/project.xml b/javadoc/nbproject/project.xml --- a/javadoc/nbproject/project.xml +++ b/javadoc/nbproject/project.xml @@ -165,15 +165,6 @@ - org.netbeans.modules.javahelp - - - - 1 - 1.0 - - - org.netbeans.modules.lexer @@ -260,7 +251,7 @@ - 8.6 + 8.21 diff --git a/javadoc/src/org/netbeans/modules/javadoc/search/IndexSearch.java b/javadoc/src/org/netbeans/modules/javadoc/search/IndexSearch.java --- a/javadoc/src/org/netbeans/modules/javadoc/search/IndexSearch.java +++ b/javadoc/src/org/netbeans/modules/javadoc/search/IndexSearch.java @@ -62,7 +62,6 @@ import javax.swing.SwingUtilities; import org.netbeans.api.java.source.ElementHandle; import org.netbeans.api.java.source.ui.ElementOpen; -import org.netbeans.api.javahelp.Help; import org.netbeans.modules.javadoc.settings.DocumentationSettings; import org.openide.awt.HtmlBrowser; import org.openide.util.Exceptions; @@ -75,7 +74,6 @@ import org.openide.awt.Mnemonics; import org.openide.filesystems.FileObject; import org.openide.util.HelpCtx; -import org.openide.util.Lookup; import org.openide.util.Mutex; import org.openide.util.NbBundle; import org.openide.util.Utilities; @@ -424,9 +422,7 @@ // //GEN-END:initComponents private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpButtonActionPerformed - Help help = Lookup.getDefault().lookup(Help.class); - - help.showHelp(getHelpCtx()); + getHelpCtx().display(); }//GEN-LAST:event_helpButtonActionPerformed private void showSource (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showSource diff --git a/javahelp/manifest.mf b/javahelp/manifest.mf --- a/javahelp/manifest.mf +++ b/javahelp/manifest.mf @@ -1,7 +1,7 @@ Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.javahelp/1 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/javahelp/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 2.25 +OpenIDE-Module-Specification-Version: 2.26 OpenIDE-Module-Provides: org.netbeans.api.javahelp.Help OpenIDE-Module-Requires: org.openide.modules.InstalledFileLocator, org.openide.modules.ModuleFormat2 OpenIDE-Module-Layer: org/netbeans/modules/javahelp/resources/layer.xml diff --git a/javahelp/nbproject/project.xml b/javahelp/nbproject/project.xml --- a/javahelp/nbproject/project.xml +++ b/javahelp/nbproject/project.xml @@ -111,7 +111,7 @@ - 8.0 + 8.21 diff --git a/javahelp/src/org/netbeans/api/javahelp/Help.java b/javahelp/src/org/netbeans/api/javahelp/Help.java --- a/javahelp/src/org/netbeans/api/javahelp/Help.java +++ b/javahelp/src/org/netbeans/api/javahelp/Help.java @@ -69,6 +69,8 @@ public abstract Boolean isValidID(String id, boolean force); /** Shows help. + *

Note that for basic usage it may suffice to call {@link HelpCtx#display}, + * avoiding any direct dependency on this module. * @param ctx help context */ public void showHelp(HelpCtx ctx) { diff --git a/javahelp/src/org/netbeans/modules/javahelp/JavaHelp.java b/javahelp/src/org/netbeans/modules/javahelp/JavaHelp.java --- a/javahelp/src/org/netbeans/modules/javahelp/JavaHelp.java +++ b/javahelp/src/org/netbeans/modules/javahelp/JavaHelp.java @@ -95,6 +95,7 @@ import org.openide.util.TaskListener; import org.openide.util.Utilities; import org.openide.util.lookup.ServiceProvider; +import org.openide.util.lookup.ServiceProviders; import org.openide.windows.WindowManager; // [PENDING] should event dispatch thread be used thruout? @@ -102,8 +103,11 @@ /** Help implementation using the JavaHelp 1.x system. * @author Jesse Glick, Richard Gregor */ -@ServiceProvider(service=Help.class) -public final class JavaHelp extends AbstractHelp implements AWTEventListener { +@ServiceProviders({ + @ServiceProvider(service=Help.class), + @ServiceProvider(service=HelpCtx.Displayer.class) +}) +public final class JavaHelp extends AbstractHelp implements HelpCtx.Displayer, AWTEventListener { /** Make a JavaHelp implementation of the Help.Impl interface. *Or, use {@link #getDefaultJavaHelp}. @@ -511,6 +515,27 @@ return jh; } + @Override public boolean display(HelpCtx help) { + String id = help.getHelpID(); + if (id != null) { + if (isValidID(id, true)) { + showHelp(help, true); + return true; + } else { + return false; + } + } else { + URL u = help.getHelp(); + if (u != null) { + // or use URLDisplayer? + showHelp(u); + return true; + } else { + return false; + } + } + } + /** Handle modal dialogs opening and closing. Note reparentToFrameLater state = rTFL. * Cases: * 1. No viewer open. Dialog opened. Push it on stack. rTFL = false. diff --git a/openide.explorer/nbproject/project.xml b/openide.explorer/nbproject/project.xml --- a/openide.explorer/nbproject/project.xml +++ b/openide.explorer/nbproject/project.xml @@ -94,7 +94,7 @@ - 8.0 + 8.21 diff --git a/openide.explorer/src/org/openide/explorer/propertysheet/PropertySheet.java b/openide.explorer/src/org/openide/explorer/propertysheet/PropertySheet.java --- a/openide.explorer/src/org/openide/explorer/propertysheet/PropertySheet.java +++ b/openide.explorer/src/org/openide/explorer/propertysheet/PropertySheet.java @@ -63,7 +63,6 @@ import java.lang.ref.Reference; import java.lang.ref.WeakReference; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -71,7 +70,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.AbstractAction; import javax.swing.Action; @@ -93,7 +91,6 @@ import org.openide.nodes.NodeAdapter; import org.openide.util.Exceptions; import org.openide.util.HelpCtx; -import org.openide.util.Lookup; import org.openide.util.Mutex; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; @@ -1089,40 +1086,9 @@ public void actionPerformed(ActionEvent e) { HelpCtx ctx = getContext(); - if (ctx == null) { + if (ctx == null || !ctx.display()) { Toolkit.getDefaultToolkit().beep(); - - return; } - - try { - //Copied from original property sheet implementation - Class c = Lookup.getDefault().lookup(ClassLoader.class).loadClass( - "org.netbeans.api.javahelp.Help" - ); // NOI18N - - Object o = Lookup.getDefault().lookup(c); - - if (o != null) { - Method m = c.getMethod("showHelp", // NOI18N - new Class[] { HelpCtx.class } - ); - - if (m != null) { //Unit tests - m.invoke(o, new Object[] { ctx }); - } - - return; - } - } catch (ClassNotFoundException cnfe) { - // ignore - maybe javahelp module is not installed, not so strange - } catch (Exception ee) { - // potentially more serious - Logger.getLogger(PropertySheet.class.getName()).log(Level.WARNING, null, ee); - } - - // Did not work. - Toolkit.getDefaultToolkit().beep(); } public HelpCtx getContext() { diff --git a/openide.util/apichanges.xml b/openide.util/apichanges.xml --- a/openide.util/apichanges.xml +++ b/openide.util/apichanges.xml @@ -51,6 +51,28 @@ Actions API + + +

HelpCtx.display added + + + + +

+ Modules calling org.netbeans.api.javahelp.Help.showHelp + via reflection should use this new API instead. +

+
+ +

+ To permit modules to display help pages where available without + a direct dependency on the JavaHelp API, HelpCtx.display() + was added together with a matching SPI. +

+
+ + + RequestProcessor tweaks diff --git a/openide.util/manifest.mf b/openide.util/manifest.mf --- a/openide.util/manifest.mf +++ b/openide.util/manifest.mf @@ -1,5 +1,5 @@ Manifest-Version: 1.0 OpenIDE-Module: org.openide.util OpenIDE-Module-Localizing-Bundle: org/openide/util/Bundle.properties -OpenIDE-Module-Specification-Version: 8.20 +OpenIDE-Module-Specification-Version: 8.21 diff --git a/openide.util/src/org/openide/util/HelpCtx.java b/openide.util/src/org/openide/util/HelpCtx.java --- a/openide.util/src/org/openide/util/HelpCtx.java +++ b/openide.util/src/org/openide/util/HelpCtx.java @@ -51,6 +51,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JComponent; +import org.openide.util.lookup.ServiceProvider; /** Provides help for any window or other feature in the system. * It is designed to be JavaHelp-compatible and to use the same tactics when @@ -120,6 +121,21 @@ return helpID; } + /** + * Displays the help page in a supported viewer, if any. + * @return true if this help was displayed successfully + * @since 8.21 + * @see org.openide.util.HelpCtx.Displayer#display + */ + public boolean display() { + for (Displayer d : Lookup.getDefault().lookupAll(Displayer.class)) { + if (d.display(this)) { + return true; + } + } + return false; + } + // object identity @Override public int hashCode() { @@ -269,4 +285,23 @@ */ public HelpCtx getHelpCtx(); } + + /** + * Service to display a {@link HelpCtx} in a help viewer. + * Permits modules with minimal API dependencies to display JavaHelp where supported. + * @see ServiceProvider + * @see #display() + * @since 8.21 + */ + public interface Displayer { + + /** + * Displays a help page. + * @param help a help ID to display + * @return true if it was displayed successfully + */ + boolean display(HelpCtx help); + + } + } diff --git a/refactoring.api/nbproject/project.xml b/refactoring.api/nbproject/project.xml --- a/refactoring.api/nbproject/project.xml +++ b/refactoring.api/nbproject/project.xml @@ -59,15 +59,6 @@
- org.netbeans.modules.javahelp - - - - 1 - 2.9 - - - org.netbeans.modules.projectapi @@ -165,7 +156,7 @@ - 8.0 + 8.21 diff --git a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ParametersPanel.java b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ParametersPanel.java --- a/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ParametersPanel.java +++ b/refactoring.api/src/org/netbeans/modules/refactoring/spi/impl/ParametersPanel.java @@ -55,7 +55,6 @@ import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import org.netbeans.api.javahelp.Help; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandleFactory; import org.netbeans.modules.refactoring.api.AbstractRefactoring; @@ -345,8 +344,10 @@ }//GEN-LAST:event_preview private void helpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpActionPerformed - Help _help = (Help) Lookup.getDefault().lookup(Help.class); - _help.showHelp(getHelpCtx()); + HelpCtx ctx = getHelpCtx(); + if (ctx != null) { + ctx.display(); + } }//GEN-LAST:event_helpActionPerformed private void backActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backActionPerformed diff --git a/xml.multiview/nbproject/project.xml b/xml.multiview/nbproject/project.xml --- a/xml.multiview/nbproject/project.xml +++ b/xml.multiview/nbproject/project.xml @@ -143,7 +143,7 @@ - 8.0 + 8.21 diff --git a/xml.multiview/src/org/netbeans/modules/xml/multiview/ui/AbstractDesignEditor.java b/xml.multiview/src/org/netbeans/modules/xml/multiview/ui/AbstractDesignEditor.java --- a/xml.multiview/src/org/netbeans/modules/xml/multiview/ui/AbstractDesignEditor.java +++ b/xml.multiview/src/org/netbeans/modules/xml/multiview/ui/AbstractDesignEditor.java @@ -56,8 +56,6 @@ import org.openide.windows.TopComponent; import org.openide.util.HelpCtx; import org.openide.actions.SaveAction; -import java.lang.reflect.Method; -import org.openide.util.Lookup; /** * The ComponentPanel three pane editor. This is basically a container that implements the ExplorerManager @@ -228,36 +226,9 @@ public void actionPerformed(java.awt.event.ActionEvent e) { HelpCtx ctx = getContext(); - if (ctx == null) { + if (ctx == null || !ctx.display()) { java.awt.Toolkit.getDefaultToolkit().beep(); - return; } - - try { - //Copied from original property sheet implementation - Class c = ((ClassLoader)Lookup.getDefault().lookup( - ClassLoader.class)).loadClass( - "org.netbeans.api.javahelp.Help"); // NOI18N - - Object o = Lookup.getDefault().lookup(c); - if (o != null) { - Method m = c.getMethod("showHelp", // NOI18N - new Class[] {HelpCtx.class}); - - if (m != null) { //Unit tests - m.invoke(o, new Object[] {ctx}); - } - return; - } - } catch (ClassNotFoundException cnfe) { - // ignore - maybe javahelp module is not installed, not so strange - } catch (Exception ee) { - // potentially more serious - org.openide.ErrorManager.getDefault().notify( - org.openide.ErrorManager.INFORMATIONAL, ee); - } - // Did not work. - java.awt.Toolkit.getDefaultToolkit().beep(); } private HelpCtx getContext() {