1 /******************************************************************************* 2 * Copyright (c) 2005, 2006 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.ui.navigator; 12 13 import org.eclipse.jface.viewers.ISelectionProvider; 14 import org.eclipse.swt.widgets.Shell; 15 import org.eclipse.ui.IEditorSite; 16 import org.eclipse.ui.IViewSite; 17 import org.eclipse.ui.internal.navigator.CommonViewerSiteDelegate; 18 import org.eclipse.ui.internal.navigator.CommonViewerSiteIEditorPartSiteDelegate; 19 import org.eclipse.ui.internal.navigator.CommonViewerSiteIPageSiteDelegate; 20 import org.eclipse.ui.internal.navigator.CommonViewerSiteIViewSiteDelegate; 21 import org.eclipse.ui.part.IPageSite; 22 23 /** 24 * Allows clients to create {@link ICommonViewerSite} for a variety of contexts. 25 * The {@link ICommonViewerSite} may be used by the 26 * {@link NavigatorActionService} to allow customization for any 27 * {@link CommonActionProvider} used by a particular instance of the Common 28 * Navigator. 29 * 30 * 31 * @since 3.2 32 */ 33 public final class CommonViewerSiteFactory { 34 /** 35 * 36 * @param aViewSite 37 * The viewer site that should be delegated to to satisfy the 38 * contract of ICommonViewerSite. 39 * @return An ICommonViewerSite that delegates to the given parameter. 40 */ 41 public static ICommonViewerWorkbenchSite createCommonViewerSite( 42 IViewSite aViewSite) { 43 return new CommonViewerSiteIViewSiteDelegate(aViewSite); 44 } 45 46 /** 47 * 48 * @param aEditorSite 49 * The editor site that should be delegated to to satisfy the 50 * contract of ICommonViewerSite. 51 * @return An ICommonViewerSite that delegates to the given parameter. 52 */ 53 public static ICommonViewerWorkbenchSite createCommonViewerSite( 54 IEditorSite aEditorSite) { 55 return new CommonViewerSiteIEditorPartSiteDelegate(aEditorSite); 56 } 57 58 /** 59 * 60 * @param anId 61 * The unique identifier corresponding to the abstract viewer for 62 * the returned ICommonViewerSite. 63 * 64 * @param aSelectionProvider 65 * The selection provider that will initially be returned by 66 * {@link ICommonViewerSite#getSelectionProvider()} 67 * 68 * @param aShell 69 * The shell that will be returned by 70 * {@link ICommonViewerSite#getShell()} 71 * @return An ICommonViewerSite that delegates to the given parameter. 72 */ 73 public static ICommonViewerSite createCommonViewerSite(String anId, 74 ISelectionProvider aSelectionProvider, Shell aShell) { 75 return new CommonViewerSiteDelegate(anId, aSelectionProvider, aShell); 76 } 77 78 /** 79 * 80 * @param anId 81 * The unique identifier corresponding to the abstract viewer for 82 * the returned ICommonViewerSite. 83 * @param aPageSite 84 * The page site that should be delegated to to satisfy the 85 * contract of ICommonViewerSite. 86 * @return An ICommonViewerSite that delegates to the given parameter. 87 */ 88 public static ICommonViewerSite createCommonViewerSite(String anId, 89 IPageSite aPageSite) { 90 return new CommonViewerSiteIPageSiteDelegate(anId, aPageSite); 91 } 92 93 } 94