Example usage for org.eclipse.jface.resource JFaceResources getImageRegistry

List of usage examples for org.eclipse.jface.resource JFaceResources getImageRegistry

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getImageRegistry.

Prototype

public static ImageRegistry getImageRegistry() 

Source Link

Document

Returns the image registry for JFace itself.

Usage

From source file:org.talend.mdm.repository.ui.actions.RenameObjectActionTest.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(/*from  w  ww .ja  v  a  2  s .co m*/
            ExAdapterManager.getAdapter(new RepositoryResourceUtil(), IRepositoryResourceUtilExAdapter.class))
            .thenReturn(mockAdapter);

    PowerMockito.mockStatic(MDMWorbenchPlugin.class);
    when(MDMWorbenchPlugin.getImageDescriptor(anyString())).thenReturn(mock(ImageDescriptor.class));

    PowerMockito.mockStatic(ImageCache.class);
    ImageDescriptor imgDesc = mock(ImageDescriptor.class);
    when(ImageCache.getImage(anyString())).thenReturn(imgDesc);
    //

    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(IProxyRepositoryFactory.class);
    when(CoreRuntimePlugin.getInstance().getProxyRepositoryFactory()).thenReturn(repositoryFactory);

    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);

    resourceProviderM = mock(IRepositoryNodeResourceProvider.class);
    when(rncMock.getResourceProvider()).thenReturn(resourceProviderM);

    when(repositoryFactory.isEditableAndLockIfPossible((Item) anyObject())).thenReturn(true);

}

From source file:org.talend.mdm.repository.utils.RepositoryResourceUtilTest.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 2  s.  c  om
            ExAdapterManager.getAdapter(new RepositoryResourceUtil(), IRepositoryResourceUtilExAdapter.class))
            .thenReturn(mockAdapter);

    PowerMockito.mockStatic(CoreRuntimePlugin.class);
    CoreRuntimePlugin coreRuntimePlugin = mock(CoreRuntimePlugin.class);
    when(CoreRuntimePlugin.getInstance()).thenReturn(coreRuntimePlugin);

    PowerMockito.mockStatic(RepositoryNodeProviderRegistryReader.class);
    RepositoryNodeProviderRegistryReader reader = mock(RepositoryNodeProviderRegistryReader.class);
    PowerMockito.when(RepositoryNodeProviderRegistryReader.getInstance()).thenReturn(reader);
}

From source file:org.thanlwinsoft.languagetest.eclipse.chart.XMLChartGenerator.java

License:Open Source License

public void init(IViewPart view) {
    this.view = view;
    Program p = Program.findProgram(".xml");
    if (p != null)
        imageData = p.getImageData();/*w ww. java  2s .co m*/
    Image image = new Image(view.getSite().getShell().getDisplay(), imageData);
    JFaceResources.getImageRegistry().put("XML", image);
    this.setImageDescriptor(JFaceResources.getImageRegistry().getDescriptor("XML"));

}

From source file:org.xmind.ui.resources.ImageUtils.java

License:Open Source License

private static ImageRegistry getImageRegistry() {
    if (imageRegistry == null)
        imageRegistry = JFaceResources.getImageRegistry();
    return imageRegistry;
}

From source file:ralfstx.mylyn.bugview.internal.TaskLabelProvider.java

License:Open Source License

public Image getColumnImage(Object element, int columnIndex) {
    Image result = null;/*from   w w  w.  ja  v a 2  s .c  o  m*/
    if (element instanceof ITask) {
        if (columnIndex == BugView.COL_ID) {
            ITask task = (ITask) element;
            if (enhancementMatcher.matches(task)) {
                result = JFaceResources.getImageRegistry().get(ENHANCEMENT_ICON);
            } else {
                result = JFaceResources.getImageRegistry().get(DEFECT_ICON);
            }
        }
    }
    return result;
}

From source file:ralfstx.mylyn.bugview.internal.TaskLabelProvider.java

License:Open Source License

private static void initializeImages() {
    ImageRegistry imageRegistry = JFaceResources.getImageRegistry();
    registeImage(DEFECT_ICON, "/icons/defect.png", imageRegistry);
    registeImage(ENHANCEMENT_ICON, "/icons/enhancement.png", imageRegistry);

}

From source file:tern.eclipse.jface.images.TernImagesRegistry.java

License:Open Source License

/**
 * Returns the image from the image registry with the given key.
 * //from w ww.j  a v  a 2s  .  com
 * @param key
 *            of the image
 * @return the image from the image registry with the given key.
 */
public static Image getImage(String key) {
    ImageRegistry imageRegistry = JFaceResources.getImageRegistry();
    return imageRegistry.get(key);
}

From source file:tern.eclipse.jface.images.TernImagesRegistry.java

License:Open Source License

/**
 * Returns the image descriptor from the image registry with the given key.
 * //w ww. ja  v a  2 s.  com
 * @param key
 *            of the image
 * @return the image descriptor from the image registry with the given key.
 */
public static ImageDescriptor getImageDescriptor(String key) {
    ImageRegistry imageRegistry = JFaceResources.getImageRegistry();
    return imageRegistry.getDescriptor(key);
}

From source file:tern.eclipse.jface.images.TernImagesRegistry.java

License:Open Source License

private static void registerImageDescriptor(String key, ImageDescriptor descriptor) {
    ImageRegistry imageRegistry = JFaceResources.getImageRegistry();
    imageRegistry.put(key, descriptor);//from   ww w  .j  a va  2  s .c o m
}

From source file:ts.eclipse.ide.jsdt.internal.ui.JSDTTypeScriptUIImages.java

License:Open Source License

private JSDTTypeScriptUIImages(String path) {
    Bundle bundle = JSDTTypeScriptUIPlugin.getDefault().getBundle();
    ImageDescriptor descr = AbstractUIPlugin.imageDescriptorFromPlugin(bundle.getSymbolicName(), path);
    JFaceResources.getImageRegistry().put(key(), descr);
}