⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 browser.java

📁 源码为Eclipse开源开发平台桌面开发工具SWT的源代码,
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
						String title = arg1.getString();						TitleEvent newEvent = new TitleEvent(Browser.this);						newEvent.display = getDisplay();						newEvent.widget = Browser.this;						newEvent.title = title;						for (int i = 0; i < titleListeners.length; i++)							titleListeners[i].changed(newEvent);					}					break;				}				case WindowClosing : {					WindowEvent newEvent = new WindowEvent(Browser.this);					newEvent.display = getDisplay();					newEvent.widget = Browser.this;					for (int i = 0; i < closeWindowListeners.length; i++)						closeWindowListeners[i].close(newEvent);					Variant cancel = event.arguments[1];					int pCancel = cancel.getByRef();					COM.MoveMemory(pCancel, new short[]{COM.VARIANT_FALSE}, 2);					dispose();					break;				}				case WindowSetHeight : {					if (size == null) size = new Point(0, 0);					Variant arg1 = event.arguments[0];					size.y = arg1.getInt();					break;				}				case WindowSetLeft : {					if (location == null) location = new Point(0, 0);					Variant arg1 = event.arguments[0];					location.x = arg1.getInt();					break;				}				case WindowSetTop : {					if (location == null) location = new Point(0, 0);					Variant arg1 = event.arguments[0];					location.y = arg1.getInt();					break;				}				case WindowSetWidth : {					if (size == null) size = new Point(0, 0);					Variant arg1 = event.arguments[0];					size.x = arg1.getInt();					break;				}			}						/*			* Dispose all arguments passed in the OleEvent.  This must be			* done to properly release any IDispatch reference that was			* automatically addRef'ed when constructing the OleEvent.  			*/			Variant[] arguments = event.arguments;			for (int i = 0; i < arguments.length; i++) arguments[i].dispose();		}	};	site.addEventListener(BeforeNavigate2, listener);	site.addEventListener(CommandStateChange, listener);	site.addEventListener(DocumentComplete, listener);	site.addEventListener(NavigateComplete2, listener);	site.addEventListener(NewWindow2, listener);	site.addEventListener(OnVisible, listener);	site.addEventListener(ProgressChange, listener);	site.addEventListener(StatusTextChange, listener);	site.addEventListener(TitleChange, listener);	site.addEventListener(WindowClosing, listener);	site.addEventListener(WindowSetHeight, listener);	site.addEventListener(WindowSetLeft, listener);	site.addEventListener(WindowSetTop, listener);	site.addEventListener(WindowSetWidth, listener);			Variant variant = new Variant(true);	auto.setProperty(RegisterAsBrowser, variant);	variant.dispose();}/**	  * Adds the listener to receive events. * <p> * * @param listener the listener * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> *  * @exception SWTError <ul> *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> * * @since 3.0 */public void addCloseWindowListener(CloseWindowListener listener) {	checkWidget();	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);		CloseWindowListener[] newCloseWindowListeners = new CloseWindowListener[closeWindowListeners.length + 1];	System.arraycopy(closeWindowListeners, 0, newCloseWindowListeners, 0, closeWindowListeners.length);	closeWindowListeners = newCloseWindowListeners;	closeWindowListeners[closeWindowListeners.length - 1] = listener;}/**	  * Adds the listener to receive events. * <p> * * @param listener the listener * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> *  * @exception SWTError <ul> *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> * * @since 3.0 */public void addLocationListener(LocationListener listener) {	checkWidget();	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);		LocationListener[] newLocationListeners = new LocationListener[locationListeners.length + 1];	System.arraycopy(locationListeners, 0, newLocationListeners, 0, locationListeners.length);	locationListeners = newLocationListeners;	locationListeners[locationListeners.length - 1] = listener;}/**	  * Adds the listener to receive events. * <p> * * @param listener the listener * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> *  * @exception SWTError <ul> *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> * * @since 3.0 */public void addOpenWindowListener(OpenWindowListener listener) {	checkWidget();	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);	OpenWindowListener[] newOpenWindowListeners = new OpenWindowListener[openWindowListeners.length + 1];	System.arraycopy(openWindowListeners, 0, newOpenWindowListeners, 0, openWindowListeners.length);	openWindowListeners = newOpenWindowListeners;	openWindowListeners[openWindowListeners.length - 1] = listener;}/**	  * Adds the listener to receive events. * <p> * * @param listener the listener * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> *  * @exception SWTError <ul> *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> * * @since 3.0 */public void addProgressListener(ProgressListener listener) {	checkWidget();	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);	ProgressListener[] newProgressListeners = new ProgressListener[progressListeners.length + 1];	System.arraycopy(progressListeners, 0, newProgressListeners, 0, progressListeners.length);	progressListeners = newProgressListeners;	progressListeners[progressListeners.length - 1] = listener;}/**	  * Adds the listener to receive events. * <p> * * @param listener the listener * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> *  * @exception SWTError <ul> *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> * * @since 3.0 */public void addStatusTextListener(StatusTextListener listener) {	checkWidget();	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);	StatusTextListener[] newStatusTextListeners = new StatusTextListener[statusTextListeners.length + 1];	System.arraycopy(statusTextListeners, 0, newStatusTextListeners, 0, statusTextListeners.length);	statusTextListeners = newStatusTextListeners;	statusTextListeners[statusTextListeners.length - 1] = listener;}/**	  * Adds the listener to receive events. * <p> * * @param listener the listener * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> *  * @exception SWTError <ul> *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> * * @since 3.0 */public void addTitleListener(TitleListener listener) {	checkWidget();	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);	TitleListener[] newTitleListeners = new TitleListener[titleListeners.length + 1];	System.arraycopy(titleListeners, 0, newTitleListeners, 0, titleListeners.length);	titleListeners = newTitleListeners;	titleListeners[titleListeners.length - 1] = listener;}/**	  * Adds the listener to receive events. * <p> * * @param listener the listener * * @exception IllegalArgumentException <ul> *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> *  * @exception SWTError <ul> *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> * * @since 3.0 */public void addVisibilityWindowListener(VisibilityWindowListener listener) {	checkWidget();	if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);	VisibilityWindowListener[] newVisibilityWindowListeners = new VisibilityWindowListener[visibilityWindowListeners.length + 1];	System.arraycopy(visibilityWindowListeners, 0, newVisibilityWindowListeners, 0, visibilityWindowListeners.length);	visibilityWindowListeners = newVisibilityWindowListeners;	visibilityWindowListeners[visibilityWindowListeners.length - 1] = listener;}/** * Navigate to the previous session history item. * * @return <code>true</code> if the operation was successful and <code>false</code> otherwise * * @exception SWTError <ul> *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> * * @see #forward *  * @since 3.0 */public boolean back() {	checkWidget();	if (!back) return false;	int[] rgdispid = auto.getIDsOfNames(new String[] { "GoBack" }); //$NON-NLS-1$	Variant pVarResult = auto.invoke(rgdispid[0]);	return pVarResult != null && pVarResult.getType() == OLE.VT_EMPTY;}protected void checkSubclass() {	String name = getClass().getName();	int index = name.lastIndexOf('.');	if (!name.substring(0, index + 1).equals(PACKAGE_PREFIX)) {		SWT.error(SWT.ERROR_INVALID_SUBCLASS);	}}/** * Navigate to the next session history item. * * @return <code>true</code> if the operation was successful and <code>false</code> otherwise * * @exception SWTError <ul> *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> *  * @see #back *  * @since 3.0 */public boolean forward() {	checkWidget();	if (!forward) return false;	int[] rgdispid = auto.getIDsOfNames(new String[] { "GoForward" }); //$NON-NLS-1$	Variant pVarResult = auto.invoke(rgdispid[0]);	return pVarResult != null && pVarResult.getType() == OLE.VT_EMPTY;}/** * Returns <code>true</code> if the receiver can navigate to the  * previous session history item, and <code>false</code> otherwise. * * @return the receiver's back command enabled state * * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> *  * @see #back */public boolean isBackEnabled() {	checkWidget();	return back;}/** * Returns <code>true</code> if the receiver can navigate to the  * next session history item, and <code>false</code> otherwise. * * @return the receiver's forward command enabled state * * @exception SWTException <ul> *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> *  * @see #forward */public boolean isForwardEnabled() {	checkWidget();	return forward;}/** * Returns the current URL. * * @return the current URL or an empty <code>String</code> if there is no current URL * * @exception SWTError <ul> *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> * * @see #setUrl *  * @since 3.0 */public String getUrl() {	checkWidget();	int[] rgdispid = auto.getIDsOfNames(new String[] { "LocationURL" }); //$NON-NLS-1$	Variant pVarResult = auto.getProperty(rgdispid[0]);	if (pVarResult == null || pVarResult.getType() != OLE.VT_BSTR)		return "";	return pVarResult.getString();}/** * Refresh the current page. * * @exception SWTError <ul> *    <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> *    <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> * </ul> *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -