1 11 package org.eclipse.ui.internal.part; 12 13 import org.eclipse.swt.widgets.Composite; 14 import org.eclipse.ui.IEditorInput; 15 import org.eclipse.ui.IKeyBindingService; 16 import org.eclipse.ui.IMemento; 17 import org.eclipse.ui.IWorkbenchPage; 18 import org.eclipse.ui.internal.components.framework.ComponentException; 19 import org.eclipse.ui.internal.components.framework.Components; 20 import org.eclipse.ui.internal.components.framework.IServiceProvider; 21 import org.eclipse.ui.internal.part.components.services.IActionBarContributorFactory; 22 import org.eclipse.ui.internal.part.components.services.INameable; 23 import org.eclipse.ui.internal.part.components.services.IPartActionBars; 24 import org.eclipse.ui.internal.part.components.services.IPartDescriptor; 25 import org.eclipse.ui.internal.part.components.services.ISavedState; 26 import org.eclipse.ui.internal.part.components.services.ISecondaryId; 27 import org.eclipse.ui.internal.part.components.services.ISelectionHandler; 28 import org.eclipse.ui.internal.part.components.services.IStatusFactory; 29 import org.eclipse.ui.internal.part.components.services.IStatusHandler; 30 import org.eclipse.ui.internal.part.components.services.ISystemLog; 31 import org.osgi.framework.Bundle; 32 33 38 public class StandardWorkbenchServices { 39 ISelectionHandler selectionHandler; 40 IEditorInput editorInput; 41 Bundle pluginBundle; 42 Composite parentComposite; 43 IWorkbenchPage page; 44 INameable nameable; 45 IStatusFactory statusFactory; 47 IPartDescriptor descriptor; 48 ISecondaryId secondaryId; 50 ISystemLog log; 51 IMemento state; 52 IKeyBindingService keyBindingService; 53 IStatusHandler statusHandler; 54 55 IServiceProvider componentProvider; 56 IPartActionBars partActionBars; 57 IActionBarContributorFactory sharedActionBarsFactory; 58 59 public StandardWorkbenchServices(IServiceProvider availableServices) throws ComponentException { 60 componentProvider = availableServices; 61 62 pluginBundle = (Bundle) Components.queryInterface(availableServices, 63 Bundle.class); 64 parentComposite = (Composite) Components.queryInterface(availableServices, 65 Composite.class); 66 editorInput = (IEditorInput) Components.queryInterface(availableServices, 67 IEditorInput.class); 68 page = (IWorkbenchPage) Components.queryInterface(availableServices, 69 IWorkbenchPage.class); 70 partActionBars = (IPartActionBars) Components.queryInterface(availableServices, 71 IPartActionBars.class); 72 selectionHandler = (ISelectionHandler) Components.queryInterface(availableServices, 73 ISelectionHandler.class); 74 nameable = (INameable) Components.queryInterface(availableServices, 75 INameable.class); 76 state = ((ISavedState) Components.queryInterface(availableServices, 77 ISavedState.class)).getState(); 78 statusFactory = (IStatusFactory) Components.queryInterface(availableServices, 79 IStatusFactory.class); 80 descriptor = (IPartDescriptor) Components.queryInterface(availableServices, 81 IPartDescriptor.class); 82 secondaryId = (ISecondaryId) Components.queryInterface(availableServices, 83 ISecondaryId.class); 84 sharedActionBarsFactory = (IActionBarContributorFactory) Components.queryInterface(availableServices, 85 IActionBarContributorFactory.class); 86 log = (ISystemLog) Components.queryInterface(availableServices, 87 ISystemLog.class); 88 keyBindingService = (IKeyBindingService) Components.queryInterface(availableServices, 89 IKeyBindingService.class); 90 statusHandler = (IStatusHandler) Components.queryInterface(availableServices, 91 IStatusHandler.class); 92 } 93 94 public IStatusHandler getStatusHandler() { 95 return statusHandler; 96 } 97 98 public IKeyBindingService getKeyBindingService() { 99 return keyBindingService; 100 } 101 102 public IActionBarContributorFactory getActionBarContributorFactory() { 103 return sharedActionBarsFactory; 104 } 105 106 public IPartActionBars getActionBars() { 107 return partActionBars; 108 } 109 110 public Object getAdapter(Class key) { 111 try { 112 return componentProvider.getService(key); 113 } catch (ComponentException e) { 114 log.log(e); 115 return null; 116 } 117 } 118 119 122 public ISecondaryId getSecondaryId() { 123 return secondaryId; 124 } 125 public IPartDescriptor getDescriptor() { 132 return descriptor; 133 } 134 public IEditorInput getEditorInput() { 135 return editorInput; 136 } 137 public INameable getNameable() { 138 return nameable; 139 } 140 141 142 public IWorkbenchPage getPage() { 143 return page; 144 } 145 public Composite getParentComposite() { 146 return parentComposite; 147 } 148 public Bundle getPluginBundle() { 149 return pluginBundle; 150 } 151 public IMemento getState() { 152 return state; 153 } 154 public ISelectionHandler getSelectionHandler() { 155 return selectionHandler; 156 } 157 public IStatusFactory getStatusFactory() { 158 return statusFactory; 159 } 160 } 161 | Popular Tags |