List of usage examples for org.eclipse.jface.resource JFaceResources getImageRegistry
public static ImageRegistry getImageRegistry()
From source file:org.polarsys.reqcycle.styling.ui.dialogs.IconRegistry.java
License:Open Source License
private static Map<String, Descriptor> init() { Map<String, Descriptor> result = new HashMap<String, Descriptor>(); IConfigurationElement[] elements = Platform.getExtensionRegistry() .getConfigurationElementsFor(Activator.PLUGIN_ID, EXT_ID); for (IConfigurationElement e : elements) { String pluginId = e.getContributor().getName(); String path = e.getAttribute("path"); ImageDescriptor createFromURL = ImageDescriptor .createFromURL(Platform.getBundle(pluginId).getEntry(path)); String id = pluginId + path; JFaceResources.getImageRegistry().put(id, createFromURL); Descriptor d = new Descriptor(); d.id = id;//w w w . ja va 2 s . com result.put(id, d); } return result; }
From source file:org.pwsafe.passwordsafeswt.PasswordSafeJFace.java
License:Open Source License
/** * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) *///from ww w . j av a 2 s. c om @Override protected void configureShell(final Shell newShell) { super.configureShell(newShell); newShell.setText(PasswordSafeJFace.APP_NAME); final Image jpwIcon = IOUtils.getImage(PasswordSafeJFace.class, "/org/pwsafe/passwordsafeswt/images/cpane.ico"); //$NON-NLS-1$ newShell.setImage(jpwIcon); // provide it for the rest of jpwsafe: JFaceResources.getImageRegistry().put(JPW_ICON, jpwIcon); Window.setDefaultImage(jpwIcon); WidgetPreferences.tuneShell(newShell, getClass()); startOpeningDialogThread(newShell); }
From source file:org.pwsafe.passwordsafeswt.util.IOUtils.java
License:Open Source License
/** * Returns an image stored in the classpath at the specified path * /* w w w . j a va 2 s . com*/ * @param clazz Class The class relative to which to find the image * @param path String The path to the image file * @return Image The image stored in the file at the specified path */ public static Image getImage(Class<?> clazz, String path) { String key = clazz.getName() + '|' + path; final ImageRegistry imageRegistry = JFaceResources.getImageRegistry(); Image image = imageRegistry.get(key); if (image == null) { imageRegistry.put(key, ImageDescriptor.createFromFile(clazz, path)); image = imageRegistry.get(key); } return image; }
From source file:org.python.pydev.ui.EmulatedNativeCheckBoxLabelProvider.java
License:Open Source License
public EmulatedNativeCheckBoxLabelProvider(ColumnViewer viewer) { if (JFaceResources.getImageRegistry().getDescriptor(CHECKED_KEY) == null) { workaround(viewer.getControl().getDisplay()); JFaceResources.getImageRegistry().put(CHECKED_KEY, makeShot(viewer.getControl(), true)); JFaceResources.getImageRegistry().put(UNCHECK_KEY, makeShot(viewer.getControl(), false)); }// w w w . j a v a2s. c om }
From source file:org.python.pydev.ui.EmulatedNativeCheckBoxLabelProvider.java
License:Open Source License
@Override public Image getImage(Object element) { if (isChecked(element)) { return JFaceResources.getImageRegistry().get(CHECKED_KEY); } else {/*w w w. j av a 2s .c om*/ return JFaceResources.getImageRegistry().get(UNCHECK_KEY); } }
From source file:org.reuseware.application.taipan.figures.ShipShape.java
License:Open Source License
protected Image getImageImage(String path) { Image image = JFaceResources.getImageRegistry().get(path); if (image == null) { ImageDescriptor descriptor = AbstractUIPlugin .imageDescriptorFromPlugin("org.reuseware.application.taipan", path); //$NON-NLS-1$ if (descriptor == null) { descriptor = ImageDescriptor.getMissingImageDescriptor(); }/*from ww w .ja va2s . c om*/ JFaceResources.getImageRegistry().put(path, image = descriptor.createImage()); } return image; }
From source file:org.seasar.eclipse.common.util.StaticImageLoader.java
License:Apache License
public static void loadResources(Class holder, String name) { loadResources(JFaceResources.getImageRegistry(), holder, name); }
From source file:org.talend.core.ui.advanced.composite.FilteredCheckboxTree.java
License:Open Source License
/** * Create the button that clears the text. * //from w w w. j a v a2 s .c om * @param parent parent <code>Composite</code> of toolbar button */ private void createClearText(Composite parent) { // only create the button if the text widget doesn't support one natively if ((filterText.getStyle() & SWT.CANCEL) == 0) { filterToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL); filterToolBar.createControl(parent); IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$ /* * (non-Javadoc) * * @see org.eclipse.jface.action.Action#run() */ @Override public void run() { clearText(); } }; // clearTextAction.setToolTipText(WorkbenchMessages.FilteredTree_ClearToolTip); clearTextAction.setToolTipText(Messages.getString("WorkbenchMessages.FilteredTree_ClearToolTip")); //$NON-NLS-1$ clearTextAction.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON)); clearTextAction .setDisabledImageDescriptor(JFaceResources.getImageRegistry().getDescriptor(DCLEAR_ICON)); filterToolBar.add(clearTextAction); } }
From source file:org.talend.mdm.repository.ui.actions.AbstractSimpleAddActionTest.java
License:Open Source License
@Before public void setUp() throws Exception { ResourceBundle rb = mock(ResourceBundle.class); stub(method(ResourceBundle.class, "getBundle", String.class)).toReturn(rb); //$NON-NLS-1$ PowerMockito.mockStatic(JFaceResources.class); ImageRegistry registry = mock(ImageRegistry.class); when(JFaceResources.getImageRegistry()).thenReturn(registry); PowerMockito.mockStatic(CoreRuntimePlugin.class); CoreRuntimePlugin coreRuntimePlugin = mock(CoreRuntimePlugin.class); when(CoreRuntimePlugin.getInstance()).thenReturn(coreRuntimePlugin); IProxyRepositoryFactory repositoryFactory = mock(IProxyRepositoryFactory.class); when(CoreRuntimePlugin.getInstance().getProxyRepositoryFactory()).thenReturn(repositoryFactory); RepositoryContext ontextMock = mock(RepositoryContext.class); when(repositoryFactory.getRepositoryContext()).thenReturn(ontextMock); PowerMockito.mockStatic(ProjectManager.class); ProjectManager pmMock = mock(ProjectManager.class); Project pMock = mock(Project.class); User userMock = mock(User.class); when(userMock.getLogin()).thenReturn("a@b.cn"); //$NON-NLS-1$ when(pMock.getAuthor()).thenReturn(userMock); when(pmMock.getCurrentProject()).thenReturn(pMock); when(ProjectManager.getInstance()).thenReturn(pmMock); when(ontextMock.getUser()).thenReturn(userMock); IRepositoryResourceUtilExAdapter mockAdapter = PowerMockito.mock(IRepositoryResourceUtilExAdapter.class); PowerMockito.mockStatic(ExAdapterManager.class); PowerMockito.when(// ww w. ja va 2 s . co m ExAdapterManager.getAdapter(new RepositoryResourceUtil(), IRepositoryResourceUtilExAdapter.class)) .thenReturn(mockAdapter); RecycleBinNodeConfiguration recycleBinNodeConfiguration = mock(RecycleBinNodeConfiguration.class); PowerMockito.whenNew(RecycleBinNodeConfiguration.class).withNoArguments() .thenReturn(recycleBinNodeConfiguration); PowerMockito.mockStatic(ProxyRepositoryFactory.class); ProxyRepositoryFactory proxyRepositoryFactory = mock(ProxyRepositoryFactory.class); when(ProxyRepositoryFactory.getInstance()).thenReturn(proxyRepositoryFactory); IRepositoryFactory repositoryFactoryMock = mock(IRepositoryFactory.class); when(proxyRepositoryFactory.getRepositoryFactoryFromProvider()).thenReturn(repositoryFactoryMock); XmiResourceManager xmiResourceManager = mock(XmiResourceManager.class); when(repositoryFactoryMock.getResourceManager()).thenReturn(xmiResourceManager); PowerMockito.mockStatic(RepositoryNodeConfigurationManager.class); IRepositoryNodeConfiguration rncMock = mock(IRepositoryNodeConfiguration.class); when(RepositoryNodeConfigurationManager.getConfiguration((Item) anyObject())).thenReturn(rncMock); IRepositoryNodeResourceProvider resourceProviderM = mock(IRepositoryNodeResourceProvider.class); when(rncMock.getResourceProvider()).thenReturn(resourceProviderM); when(resourceProviderM.needSaveReferenceFile()).thenReturn(true); when(repositoryFactory.isEditableAndLockIfPossible((Item) anyObject())).thenReturn(true); }
From source file:org.talend.mdm.repository.ui.actions.RemoveFromRepositoryActionTest.java
License:Open Source License
@Before public void setUp() throws Exception { ResourceBundle rb = mock(ResourceBundle.class); stub(method(ResourceBundle.class, "getBundle", String.class)).toReturn(rb); //$NON-NLS-1$ PowerMockito.mockStatic(JFaceResources.class); ImageRegistry registry = mock(ImageRegistry.class); when(JFaceResources.getImageRegistry()).thenReturn(registry); PowerMockito.mockStatic(DefaultMessagesImpl.class); when(DefaultMessagesImpl.getString(anyString())).thenReturn("anyString()"); //$NON-NLS-1$ IRepositoryResourceUtilExAdapter mockAdapter = PowerMockito.mock(IRepositoryResourceUtilExAdapter.class); PowerMockito.mockStatic(ExAdapterManager.class); PowerMockito.when(/*w w w . ja v a 2s. c o m*/ ExAdapterManager.getAdapter(new RepositoryResourceUtil(), IRepositoryResourceUtilExAdapter.class)) .thenReturn(mockAdapter); PowerMockito.mockStatic(CoreRuntimePlugin.class); CoreRuntimePlugin coreRuntimePlugin = mock(CoreRuntimePlugin.class); when(CoreRuntimePlugin.getInstance()).thenReturn(coreRuntimePlugin); RepositoryContext contextMock = mock(RepositoryContext.class); PowerMockito.mockStatic(ProjectManager.class); ProjectManager pmMock = mock(ProjectManager.class); projectM = mock(Project.class); User userMock = mock(User.class); when(userMock.getLogin()).thenReturn("a@b.cn"); //$NON-NLS-1$ when(projectM.getAuthor()).thenReturn(userMock); when(pmMock.getCurrentProject()).thenReturn(projectM); when(ProjectManager.getInstance()).thenReturn(pmMock); when(contextMock.getUser()).thenReturn(userMock); repositoryFactory = mock(ProxyRepositoryFactory.class); RecycleBinNodeConfiguration recycleBinNodeConfiguration = mock(RecycleBinNodeConfiguration.class); PowerMockito.whenNew(RecycleBinNodeConfiguration.class).withNoArguments() .thenReturn(recycleBinNodeConfiguration); stub(method(ProxyRepositoryFactory.class, "getInstance")).toReturn(repositoryFactory); //$NON-NLS-1$ when(CoreRuntimePlugin.getInstance().getProxyRepositoryFactory()).thenReturn(repositoryFactory); IRepositoryFactory repositoryFactoryMock = mock(IRepositoryFactory.class); when(repositoryFactory.getRepositoryFactoryFromProvider()).thenReturn(repositoryFactoryMock); XmiResourceManager xmiResourceManager = mock(XmiResourceManager.class); when(repositoryFactoryMock.getResourceManager()).thenReturn(xmiResourceManager); PowerMockito.mockStatic(RepositoryNodeConfigurationManager.class); IRepositoryNodeConfiguration rncMock = mock(IRepositoryNodeConfiguration.class); when(RepositoryNodeConfigurationManager.getConfiguration((Item) anyObject())).thenReturn(rncMock); IRepositoryNodeResourceProvider resourceProviderM = mock(IRepositoryNodeResourceProvider.class); when(rncMock.getResourceProvider()).thenReturn(resourceProviderM); when(resourceProviderM.needSaveReferenceFile()).thenReturn(true); when(repositoryFactory.getRepositoryContext()).thenReturn(contextMock); when(repositoryFactory.isEditableAndLockIfPossible((Item) anyObject())).thenReturn(true); }