| /******************************************************************************* |
| * Copyright (c) 2004 IBM Corporation and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.ui.tests.api.workbenchpart; |
| |
| import org.eclipse.core.commands.common.EventManager; |
| import org.eclipse.core.runtime.Platform; |
| import org.eclipse.jface.util.SafeRunnable; |
| import org.eclipse.swt.graphics.Image; |
| import org.eclipse.swt.widgets.Composite; |
| import org.eclipse.ui.IMemento; |
| import org.eclipse.ui.IPropertyListener; |
| import org.eclipse.ui.ISharedImages; |
| import org.eclipse.ui.IViewPart; |
| import org.eclipse.ui.IViewSite; |
| import org.eclipse.ui.IWorkbenchPartConstants; |
| import org.eclipse.ui.IWorkbenchPartSite; |
| import org.eclipse.ui.PartInitException; |
| import org.eclipse.ui.PlatformUI; |
| |
| /** |
| * @since 3.0 |
| */ |
| public class RawIViewPart extends EventManager implements IViewPart { |
| |
| private IViewSite site; |
| |
| private String title = "SomeTitle"; |
| |
| /** |
| * |
| */ |
| public RawIViewPart() { |
| super(); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IViewPart#getViewSite() |
| */ |
| public IViewSite getViewSite() { |
| return site; |
| } |
| |
| public void setTitle(String newTitle) { |
| title = newTitle; |
| firePropertyChange(IWorkbenchPartConstants.PROP_TITLE); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IViewPart#init(org.eclipse.ui.IViewSite) |
| */ |
| public void init(IViewSite site) throws PartInitException { |
| this.site = site; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento) |
| */ |
| public void init(IViewSite site, IMemento memento) throws PartInitException { |
| this.site = site; |
| } |
| |
| /** |
| * Fires a property changed event. |
| * |
| * @param propertyId the id of the property that changed |
| */ |
| protected void firePropertyChange(final int propertyId) { |
| Object[] array = getListeners(); |
| for (int nX = 0; nX < array.length; nX++) { |
| final IPropertyListener l = (IPropertyListener) array[nX]; |
| Platform.run(new SafeRunnable() { |
| public void run() { |
| l.propertyChanged(RawIViewPart.this, propertyId); |
| } |
| }); |
| } |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IViewPart#saveState(org.eclipse.ui.IMemento) |
| */ |
| public void saveState(IMemento memento) { |
| |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IWorkbenchPart#addPropertyListener(org.eclipse.ui.IPropertyListener) |
| */ |
| public void addPropertyListener(IPropertyListener listener) { |
| addListenerObject(listener); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) |
| */ |
| public void createPartControl(Composite parent) { |
| |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IWorkbenchPart#dispose() |
| */ |
| public void dispose() { |
| |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IWorkbenchPart#getSite() |
| */ |
| public IWorkbenchPartSite getSite() { |
| return site; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IWorkbenchPart#getTitle() |
| */ |
| public String getTitle() { |
| return title; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IWorkbenchPart#getTitleImage() |
| */ |
| public Image getTitleImage() { |
| return PlatformUI.getWorkbench().getSharedImages().getImage( |
| ISharedImages.IMG_DEF_VIEW); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IWorkbenchPart#getTitleToolTip() |
| */ |
| public String getTitleToolTip() { |
| return "blah"; |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IWorkbenchPart#removePropertyListener(org.eclipse.ui.IPropertyListener) |
| */ |
| public void removePropertyListener(IPropertyListener l) { |
| removeListenerObject(l); |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.ui.IWorkbenchPart#setFocus() |
| */ |
| public void setFocus() { |
| |
| } |
| |
| /* (non-Javadoc) |
| * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) |
| */ |
| public Object getAdapter(Class adapter) { |
| return null; |
| } |
| |
| } |