Source:
private void registerFromAdaptable(final AbstractRepositoryConnector connector) { SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { AbstractRepositoryConnectorUi connectorUi = loadAdapter(connector, AbstractRepositoryConnectorUi.class); if (connectorUi != null) { TasksUiPlugin.getDefault().addRepositoryConnectorUi(connectorUi); TasksUiInternal.setConnectorForConnectorUi(connector, connectorUi); } RepositoryConnectorBranding branding = loadAdapter(connector, RepositoryConnectorBranding.class); if (branding != null) { InputStream brandingImageData = branding.getBrandingImageData(); if (brandingImageData != null) { try { TasksUiPlugin.getDefault().addBrandingIcon(connector.getConnectorKind(), getImage(brandingImageData)); } finally { closeQuietly(brandingImageData); } } InputStream overlayImageData = branding.getOverlayImageData(); if (overlayImageData != null) { try { TasksUiPlugin.getDefault().addOverlayIcon(connector.getConnectorKind(), getImageDescriptor(overlayImageData)); } finally { closeQuietly(brandingImageData); } } } } private void closeQuietly(InputStream in) { try { in.close(); } catch (IOException e) { } } @SuppressWarnings("unchecked") public <T> T loadAdapter(final AbstractRepositoryConnector connector, Class<T> klass) { T adapter = null; if (connector instanceof IAdaptable) { adapter = (T) ((IAdaptable) connector).getAdapter(klass); } if (adapter == null) { adapter = (T) Platform.getAdapterManager().loadAdapter(connector, klass.getName()); } return adapter; } private ImageDescriptor getImageDescriptor(InputStream in) { return ImageDescriptor.createFromImageData(new ImageData(in)); } private Image getImage(InputStream in) { return CommonImages.getImage(getImageDescriptor(in)); } @Override public void handleException(Throwable e) { StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, NLS.bind( "Loading of connector ui for kind ''{0}'' failed.", connector.getConnectorKind()), e)); } }); }

Target:
private void registerFromAdaptable(final AbstractRepositoryConnector connector) { SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { AbstractRepositoryConnectorUi connectorUi = loadAdapter(connector, AbstractRepositoryConnectorUi.class); if (connectorUi != null) { TasksUiPlugin.getDefault().addRepositoryConnectorUi(connectorUi); } RepositoryConnectorBranding branding = loadAdapter(connector, RepositoryConnectorBranding.class); if (branding != null) { InputStream brandingImageData = branding.getBrandingImageData(); if (brandingImageData != null) { try { TasksUiPlugin.getDefault().addBrandingIcon(connector.getConnectorKind(), getImage(brandingImageData)); } finally { closeQuietly(brandingImageData); } } InputStream overlayImageData = branding.getOverlayImageData(); if (overlayImageData != null) { try { TasksUiPlugin.getDefault().addOverlayIcon(connector.getConnectorKind(), getImageDescriptor(overlayImageData)); } finally { closeQuietly(brandingImageData); } } } } private void closeQuietly(InputStream in) { try { in.close(); } catch (IOException e) { } } @SuppressWarnings("unchecked") public <T> T loadAdapter(final AbstractRepositoryConnector connector, Class<T> klass) { T adapter = null; if (connector instanceof IAdaptable) { adapter = (T) ((IAdaptable) connector).getAdapter(klass); } if (adapter == null) { adapter = (T) Platform.getAdapterManager().loadAdapter(connector, klass.getName()); } return adapter; } private ImageDescriptor getImageDescriptor(InputStream in) { return ImageDescriptor.createFromImageData(new ImageData(in)); } private Image getImage(InputStream in) { return CommonImages.getImage(getImageDescriptor(in)); } @Override public void handleException(Throwable e) { StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, NLS.bind( "Loading of connector ui for kind ''{0}'' failed.", connector.getConnectorKind()), e)); } }); }