This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 217171
Collapse All | Expand All

(-)openide.awt/apichanges.xml (+14 lines)
Lines 50-55 Link Here
50
<apidef name="awt">AWT API</apidef>
50
<apidef name="awt">AWT API</apidef>
51
</apidefs>
51
</apidefs>
52
<changes>
52
<changes>
53
    <change id="BrowserExtensions">
54
      <api name="awt"/>
55
      <summary>Minor API extensions to allow better integration of embedded browsers.</summary>
56
      <version major="7" minor="52"/>
57
      <date day="21" month="8" year="2012"/>
58
      <author login="saubrecht"/>
59
      <compatibility addition="yes" binary="compatible" source="compatible" deprecation="no" semantic="compatible" modification="no" deletion="no"/>
60
      <description>
61
          Internal web browser can now contain an additional toolbar component: HtmlBrowser(Factory, boolean, boolean, Component)
62
          Browser implementation can pass arbitrary data to Web browser window's Lookup: HtmlBrowser.Impl.getLookup()
63
      </description>
64
      <class package="org.openide.awt" name="HtmlBrowser"/>
65
      <issue number="217171"/>
66
    </change>
53
    <change id="ToolbarWithOverflow">
67
    <change id="ToolbarWithOverflow">
54
      <api name="awt"/>
68
      <api name="awt"/>
55
      <summary>ToolbarWithOverflow class that adds an overflow button when the toolbar becomes too small to show all the available actions.</summary>
69
      <summary>ToolbarWithOverflow class that adds an overflow button when the toolbar becomes too small to show all the available actions.</summary>
(-)openide.awt/src/org/openide/awt/HtmlBrowser.java (-27 / +84 lines)
Lines 44-55 Link Here
44
44
45
package org.openide.awt;
45
package org.openide.awt;
46
46
47
import java.awt.BorderLayout;
47
import java.awt.*;
48
import java.awt.Component;
49
import java.awt.Desktop;
50
import java.awt.GridBagConstraints;
51
import java.awt.GridBagLayout;
52
import java.awt.Insets;
53
import java.awt.event.ActionEvent;
48
import java.awt.event.ActionEvent;
54
import java.awt.event.ActionListener;
49
import java.awt.event.ActionListener;
55
import java.awt.event.MouseAdapter;
50
import java.awt.event.MouseAdapter;
Lines 62-82 Link Here
62
import java.util.logging.Logger;
57
import java.util.logging.Logger;
63
import javax.accessibility.Accessible;
58
import javax.accessibility.Accessible;
64
import javax.accessibility.AccessibleContext;
59
import javax.accessibility.AccessibleContext;
65
import javax.swing.BorderFactory;
60
import javax.swing.*;
66
import javax.swing.JButton;
61
import org.openide.util.*;
67
import javax.swing.JComponent;
68
import javax.swing.JFrame;
69
import javax.swing.JLabel;
70
import javax.swing.JPanel;
71
import javax.swing.JScrollPane;
72
import javax.swing.JTextField;
73
import javax.swing.SwingUtilities;
74
import javax.swing.WindowConstants;
75
import org.openide.util.Exceptions;
76
import org.openide.util.ImageUtilities;
77
import org.openide.util.Lookup;
78
import org.openide.util.NbBundle;
79
import org.openide.util.RequestProcessor;
80
62
81
/**
63
/**
82
* Object that provides viewer for HTML pages.
64
* Object that provides viewer for HTML pages.
Lines 113-120 Link Here
113
    /** currently used implementation of browser */
95
    /** currently used implementation of browser */
114
    final Impl browserImpl;
96
    final Impl browserImpl;
115
97
116
    /** true = do not listen on changes of URL on cbLocation */
98
    /** true = ignore changes in location field */
117
    private boolean everythinkIListenInCheckBoxIsUnimportant = false;
99
    private boolean ignoreChangeInLocationField = false;
118
100
119
    /** toolbar visible property */
101
    /** toolbar visible property */
120
    private boolean toolbarVisible = false;
102
    private boolean toolbarVisible = false;
Lines 144-149 Link Here
144
    final Component browserComponent;
126
    final Component browserComponent;
145
    private JPanel head;
127
    private JPanel head;
146
    private RequestProcessor rp = new RequestProcessor();
128
    private RequestProcessor rp = new RequestProcessor();
129
    private final Component extraToolbar;
147
130
148
    // init ......................................................................
131
    // init ......................................................................
149
132
Lines 173-178 Link Here
173
     * @param statusLine visibility of statusLine
156
     * @param statusLine visibility of statusLine
174
    */
157
    */
175
    public HtmlBrowser(Factory fact, boolean toolbar, boolean statusLine) {
158
    public HtmlBrowser(Factory fact, boolean toolbar, boolean statusLine) {
159
        this( fact, toolbar, statusLine, null );
160
    }
161
162
    /**
163
    * Creates new html browser.
164
     *
165
     * @param fact Factory that is used for creation. If null is passed it searches for
166
     *             a factory providing displayable component.
167
     * @param toolbar visibility of toolbar
168
     * @param statusLine visibility of statusLine
169
     * @param extraToolbar Additional toolbar to be displayed under the default
170
     * toolbar with location field and back/forward buttons.
171
     * @since 7.52
172
    */
173
    public HtmlBrowser(Factory fact, boolean toolbar, boolean statusLine, Component extraToolbar) {
176
        Impl impl = null;
174
        Impl impl = null;
177
        Component comp = null;
175
        Component comp = null;
178
176
Lines 201-206 Link Here
201
199
202
        browserImpl = impl;
200
        browserImpl = impl;
203
        browserComponent = comp;
201
        browserComponent = comp;
202
        this.extraToolbar = extraToolbar;
204
203
205
        setLayout(new BorderLayout(0, 2));
204
        setLayout(new BorderLayout(0, 2));
206
205
Lines 373-380 Link Here
373
        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));
372
        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));
374
        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));
373
        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));
375
        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));
374
        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));
375
        if( null != extraToolbar ) {
376
            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));
377
        }
376
378
377
        head.setBorder( BorderFactory.createEmptyBorder(8, 10, 8, 10));
379
        head.setBorder( BorderFactory.createEmptyBorder(8, 10, null == extraToolbar ? 8 : 3, 10));
378
380
379
        if (browserImpl != null) {
381
        if (browserImpl != null) {
380
            bBack.setEnabled(browserImpl.isBackward());
382
            bBack.setEnabled(browserImpl.isBackward());
Lines 461-466 Link Here
461
        class URLSetter implements Runnable {
463
        class URLSetter implements Runnable {
462
            private boolean sameHosts = false;
464
            private boolean sameHosts = false;
463
465
466
            @Override
464
            public void run() {
467
            public void run() {
465
                if (!SwingUtilities.isEventDispatchThread()) {
468
                if (!SwingUtilities.isEventDispatchThread()) {
466
                    if ("nbfs".equals(url.getProtocol())) { // NOI18N
469
                    if ("nbfs".equals(url.getProtocol())) { // NOI18N
Lines 592-604 Link Here
592
     */
595
     */
593
    private void updateLocationBar() {
596
    private void updateLocationBar() {
594
        if (toolbarVisible) {
597
        if (toolbarVisible) {
595
            everythinkIListenInCheckBoxIsUnimportant = true;
598
            ignoreChangeInLocationField = true;
596
599
597
            String url = browserImpl.getLocation();
600
            String url = browserImpl.getLocation();
598
601
599
            txtLocation.setText(url);
602
            txtLocation.setText(url);
600
603
601
            everythinkIListenInCheckBoxIsUnimportant = false;
604
            ignoreChangeInLocationField = false;
602
        }
605
        }
603
    }
606
    }
604
607
Lines 673-678 Link Here
673
        /**
676
        /**
674
        * Listens on changes in HtmlBrowser.Impl.
677
        * Listens on changes in HtmlBrowser.Impl.
675
        */
678
        */
679
        @Override
676
        public void propertyChange(PropertyChangeEvent evt) {
680
        public void propertyChange(PropertyChangeEvent evt) {
677
            String property = evt.getPropertyName();
681
            String property = evt.getPropertyName();
678
682
Lines 700-715 Link Here
700
                bForward.setEnabled(browserImpl.isForward());
704
                bForward.setEnabled(browserImpl.isForward());
701
            } else if (property.equals(Impl.PROP_BACKWARD) && (bBack != null)) {
705
            } else if (property.equals(Impl.PROP_BACKWARD) && (bBack != null)) {
702
                bBack.setEnabled(browserImpl.isBackward());
706
                bBack.setEnabled(browserImpl.isBackward());
707
            } else if (property.equals(Impl.PROP_LOADING) && (bStop != null)) {
708
                bStop.setEnabled(((Boolean)evt.getNewValue()).booleanValue());
703
            }
709
            }
704
        }
710
        }
705
711
706
        /**
712
        /**
707
        * Listens on changes in HtmlBrowser visual components.
713
        * Listens on changes in HtmlBrowser visual components.
708
        */
714
        */
715
        @Override
709
        public void actionPerformed(ActionEvent e) {
716
        public void actionPerformed(ActionEvent e) {
710
            if (e.getSource() == txtLocation) {
717
            if (e.getSource() == txtLocation) {
711
                // URL manually changed
718
                // URL manually changed
712
                if (everythinkIListenInCheckBoxIsUnimportant) {
719
                if (ignoreChangeInLocationField) {
713
                    return;
720
                    return;
714
                }
721
                }
715
722
Lines 765-770 Link Here
765
        public static final String PROP_HISTORY = "history"; // NOI18N
772
        public static final String PROP_HISTORY = "history"; // NOI18N
766
773
767
        /**
774
        /**
775
         * @since 7.52
776
         */
777
        public static final String PROP_BROWSER_WAS_CLOSED = "browser.was.closed"; // NOI18N
778
779
        /**
780
         * Name of boolean property which is fired when the browser is busy loading
781
         * its content.
782
         * 
783
         * @since 7.52
784
         */
785
        public static final String PROP_LOADING = "loading"; //NOI18N
786
787
788
        private final Lookup.Provider lookupProvider;
789
790
        protected Impl() {
791
            this( EMPTY_LOOKUP_PROVIDER );
792
        }
793
794
        /**
795
         * C'tor
796
         * @param lookupProvider Provides Lookup that will appear in browser's
797
         * TopComponent.
798
         * @since 7.52
799
         * @see #getLookup()
800
         */
801
        protected Impl( Lookup.Provider lookupProvider ) {
802
            this.lookupProvider = lookupProvider;
803
        }
804
        
805
        /**
768
        * Returns visual component of html browser.
806
        * Returns visual component of html browser.
769
        *
807
        *
770
        * @return visual component of html browser.
808
        * @return visual component of html browser.
Lines 895-901 Link Here
895
         */
933
         */
896
        public void dispose() {
934
        public void dispose() {
897
        }
935
        }
936
937
        /**
938
         * The content of this Lookup will be merged into browser's TopComponent Lookup.
939
         * @return Browser's Lookup
940
         * @since 7.52
941
         * @see #Impl(org.openide.util.Lookup.Provider) 
942
         */
943
        public final Lookup getLookup() {
944
            return lookupProvider.getLookup();
898
    }
945
    }
946
    }
899
947
900
    /** A manager class which can display URLs in the proper way.
948
    /** A manager class which can display URLs in the proper way.
901
     * Might open a selected HTML browser, knows about embedded vs. external
949
     * Might open a selected HTML browser, knows about embedded vs. external
Lines 954-959 Link Here
954
        public TrivialURLDisplayer() {
1002
        public TrivialURLDisplayer() {
955
        }
1003
        }
956
1004
1005
        @Override
957
        public void showURL(URL u) {
1006
        public void showURL(URL u) {
958
            if (Desktop.isDesktopSupported()) {
1007
            if (Desktop.isDesktopSupported()) {
959
                Desktop d = Desktop.getDesktop();
1008
                Desktop d = Desktop.getDesktop();
Lines 1001-1004 Link Here
1001
            }
1050
            }
1002
        }
1051
        }
1003
    }
1052
    }
1053
1054
    private static final Lookup.Provider EMPTY_LOOKUP_PROVIDER = new Lookup.Provider() {
1055
1056
        @Override
1057
        public Lookup getLookup() {
1058
            return Lookup.EMPTY;
1004
}
1059
}
1060
    };
1061
}

Return to bug 217171