# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: D:\hg\core-main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: openide.awt/apichanges.xml --- openide.awt/apichanges.xml Base (BASE) +++ openide.awt/apichanges.xml Locally Modified (Based On LOCAL) @@ -50,6 +50,20 @@ AWT API + + + Minor API extensions to allow better integration of embedded browsers. + + + + + + Internal web browser can now contain an additional toolbar component: HtmlBrowser(Factory, boolean, boolean, Component) + Browser implementation can pass arbitrary data to Web browser window's Lookup: HtmlBrowser.Impl.getLookup() + + + + ToolbarWithOverflow class that adds an overflow button when the toolbar becomes too small to show all the available actions. Index: openide.awt/src/org/openide/awt/HtmlBrowser.java --- openide.awt/src/org/openide/awt/HtmlBrowser.java Base (BASE) +++ openide.awt/src/org/openide/awt/HtmlBrowser.java Locally Modified (Based On LOCAL) @@ -44,12 +44,7 @@ package org.openide.awt; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Desktop; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -62,21 +57,8 @@ import java.util.logging.Logger; import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.SwingUtilities; -import javax.swing.WindowConstants; -import org.openide.util.Exceptions; -import org.openide.util.ImageUtilities; -import org.openide.util.Lookup; -import org.openide.util.NbBundle; -import org.openide.util.RequestProcessor; +import javax.swing.*; +import org.openide.util.*; /** * Object that provides viewer for HTML pages. @@ -113,8 +95,8 @@ /** currently used implementation of browser */ final Impl browserImpl; - /** true = do not listen on changes of URL on cbLocation */ - private boolean everythinkIListenInCheckBoxIsUnimportant = false; + /** true = ignore changes in location field */ + private boolean ignoreChangeInLocationField = false; /** toolbar visible property */ private boolean toolbarVisible = false; @@ -144,6 +126,7 @@ final Component browserComponent; private JPanel head; private RequestProcessor rp = new RequestProcessor(); + private final Component extraToolbar; // init ...................................................................... @@ -173,6 +156,21 @@ * @param statusLine visibility of statusLine */ public HtmlBrowser(Factory fact, boolean toolbar, boolean statusLine) { + this( fact, toolbar, statusLine, null ); + } + + /** + * Creates new html browser. + * + * @param fact Factory that is used for creation. If null is passed it searches for + * a factory providing displayable component. + * @param toolbar visibility of toolbar + * @param statusLine visibility of statusLine + * @param extraToolbar Additional toolbar to be displayed under the default + * toolbar with location field and back/forward buttons. + * @since 7.52 + */ + public HtmlBrowser(Factory fact, boolean toolbar, boolean statusLine, Component extraToolbar) { Impl impl = null; Component comp = null; @@ -201,6 +199,7 @@ browserImpl = impl; browserComponent = comp; + this.extraToolbar = extraToolbar; setLayout(new BorderLayout(0, 2)); @@ -373,8 +372,11 @@ head.add(txtLocation, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,4), 0, 0)); head.add(bReload, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0,0,0,4), 0, 0)); head.add(bStop, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0,0,0,0), 0, 0)); + if( null != extraToolbar ) { + head.add(extraToolbar, new GridBagConstraints(0, 1, 5, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3,0,0,0), 0, 0)); + } - head.setBorder( BorderFactory.createEmptyBorder(8, 10, 8, 10)); + head.setBorder( BorderFactory.createEmptyBorder(8, 10, null == extraToolbar ? 8 : 3, 10)); if (browserImpl != null) { bBack.setEnabled(browserImpl.isBackward()); @@ -461,6 +463,7 @@ class URLSetter implements Runnable { private boolean sameHosts = false; + @Override public void run() { if (!SwingUtilities.isEventDispatchThread()) { if ("nbfs".equals(url.getProtocol())) { // NOI18N @@ -592,13 +595,13 @@ */ private void updateLocationBar() { if (toolbarVisible) { - everythinkIListenInCheckBoxIsUnimportant = true; + ignoreChangeInLocationField = true; String url = browserImpl.getLocation(); txtLocation.setText(url); - everythinkIListenInCheckBoxIsUnimportant = false; + ignoreChangeInLocationField = false; } } @@ -673,6 +676,7 @@ /** * Listens on changes in HtmlBrowser.Impl. */ + @Override public void propertyChange(PropertyChangeEvent evt) { String property = evt.getPropertyName(); @@ -700,16 +704,19 @@ bForward.setEnabled(browserImpl.isForward()); } else if (property.equals(Impl.PROP_BACKWARD) && (bBack != null)) { bBack.setEnabled(browserImpl.isBackward()); + } else if (property.equals(Impl.PROP_LOADING) && (bStop != null)) { + bStop.setEnabled(((Boolean)evt.getNewValue()).booleanValue()); } } /** * Listens on changes in HtmlBrowser visual components. */ + @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == txtLocation) { // URL manually changed - if (everythinkIListenInCheckBoxIsUnimportant) { + if (ignoreChangeInLocationField) { return; } @@ -765,6 +772,37 @@ public static final String PROP_HISTORY = "history"; // NOI18N /** + * @since 7.52 + */ + public static final String PROP_BROWSER_WAS_CLOSED = "browser.was.closed"; // NOI18N + + /** + * Name of boolean property which is fired when the browser is busy loading + * its content. + * + * @since 7.52 + */ + public static final String PROP_LOADING = "loading"; //NOI18N + + + private final Lookup.Provider lookupProvider; + + protected Impl() { + this( EMPTY_LOOKUP_PROVIDER ); + } + + /** + * C'tor + * @param lookupProvider Provides Lookup that will appear in browser's + * TopComponent. + * @since 7.52 + * @see #getLookup() + */ + protected Impl( Lookup.Provider lookupProvider ) { + this.lookupProvider = lookupProvider; + } + + /** * Returns visual component of html browser. * * @return visual component of html browser. @@ -895,7 +933,17 @@ */ public void dispose() { } + + /** + * The content of this Lookup will be merged into browser's TopComponent Lookup. + * @return Browser's Lookup + * @since 7.52 + * @see #Impl(org.openide.util.Lookup.Provider) + */ + public final Lookup getLookup() { + return lookupProvider.getLookup(); } + } /** A manager class which can display URLs in the proper way. * Might open a selected HTML browser, knows about embedded vs. external @@ -954,6 +1002,7 @@ public TrivialURLDisplayer() { } + @Override public void showURL(URL u) { if (Desktop.isDesktopSupported()) { Desktop d = Desktop.getDesktop(); @@ -1001,4 +1050,12 @@ } } } + + private static final Lookup.Provider EMPTY_LOOKUP_PROVIDER = new Lookup.Provider() { + + @Override + public Lookup getLookup() { + return Lookup.EMPTY; } + }; +}