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 764-770
Link Here
|
764 |
/** history property name */ |
771 |
/** history property name */ |
765 |
public static final String PROP_HISTORY = "history"; // NOI18N |
772 |
public static final String PROP_HISTORY = "history"; // NOI18N |
766 |
|
773 |
|
|
|
774 |
public static final String PROP_BROWSER_WAS_CLOSED = "browser.was.closed"; // NOI18N |
775 |
|
767 |
/** |
776 |
/** |
|
|
777 |
* Name of boolean property which is fired when the browser is busy loading |
778 |
* its content. |
779 |
* |
780 |
* @since 7.52 |
781 |
*/ |
782 |
public static final String PROP_LOADING = "loading"; //NOI18N |
783 |
|
784 |
/** |
768 |
* Returns visual component of html browser. |
785 |
* Returns visual component of html browser. |
769 |
* |
786 |
* |
770 |
* @return visual component of html browser. |
787 |
* @return visual component of html browser. |
Lines 895-901
Link Here
|
895 |
*/ |
912 |
*/ |
896 |
public void dispose() { |
913 |
public void dispose() { |
897 |
} |
914 |
} |
|
|
915 |
|
916 |
/** |
917 |
* The content of this Lookup will be merged into browser's TopComponent Lookup. |
918 |
* @return Browser's Lookup |
919 |
* @since 7.52 |
920 |
*/ |
921 |
public Lookup getLookup() { |
922 |
return Lookup.EMPTY; |
898 |
} |
923 |
} |
|
|
924 |
} |
899 |
|
925 |
|
900 |
/** A manager class which can display URLs in the proper way. |
926 |
/** A manager class which can display URLs in the proper way. |
901 |
* Might open a selected HTML browser, knows about embedded vs. external |
927 |
* Might open a selected HTML browser, knows about embedded vs. external |
Lines 954-959
Link Here
|
954 |
public TrivialURLDisplayer() { |
980 |
public TrivialURLDisplayer() { |
955 |
} |
981 |
} |
956 |
|
982 |
|
|
|
983 |
@Override |
957 |
public void showURL(URL u) { |
984 |
public void showURL(URL u) { |
958 |
if (Desktop.isDesktopSupported()) { |
985 |
if (Desktop.isDesktopSupported()) { |
959 |
Desktop d = Desktop.getDesktop(); |
986 |
Desktop d = Desktop.getDesktop(); |