Example usage for org.eclipse.jface.resource ImageDescriptor ImageDescriptor

List of usage examples for org.eclipse.jface.resource ImageDescriptor ImageDescriptor

Introduction

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

Prototype

protected ImageDescriptor() 

Source Link

Document

Constructs an image descriptor.

Usage

From source file:com.arc.cdt.debug.seecode.ui.internal.display.ViewToolBarBuilder.java

License:Open Source License

@Override
public void populateView(final IViewPart viewPart) {
    IViewSite vs = viewPart.getViewSite();
    final IToolBarManager tm = vs.getActionBars().getToolBarManager();

    tm.removeAll();//from w  w  w .  jav a  2s. c  o m
    for (IToolBarItem it : mItems) {
        it.addToToolBar(tm);
    }
    //<WIN32 BUG>: if the toolbar doesn't have any buttons (e.g., only
    // comboboxes), Windows version of SWT (as of 3.1M5) doesn't 
    // compute the height correctly.
    // For such cases, we must add a dummy button with an invisible 1-pixel
    // wide icon. It won't be seen in the toolbar unless the mouse happens
    // to go over it. If anyone has a better solution, please make appropriate
    // corrections. This problem has already cost me a day! (D.P.)
    if (isWindows()) {
        boolean hasButtons = false;
        for (IToolBarItem it : mItems) {
            if (it instanceof DeferredButton) {
                hasButtons = true;
                break;
            }
        }
        if (!hasButtons) {
            DeferredButton item = new DeferredButton(IAction.AS_PUSH_BUTTON);
            item.addToToolBar(tm);
            final String DUMMY_ICON = "IconToFixWindowsSWTBug";

            ImageRegistry imageRegistry = UISeeCodePlugin.getDefault().getImageRegistry();
            ImageDescriptor id = imageRegistry.getDescriptor(DUMMY_ICON);
            if (id == null) {
                final ImageData data = new ImageData(1, 15, 1,
                        new PaletteData(new RGB[] { new RGB(0, 0, 0), new RGB(255, 255, 255) }));
                data.transparentPixel = 0;
                id = new ImageDescriptor() {

                    @Override
                    public ImageData getImageData() {
                        return data;
                    }
                };
                imageRegistry.put(DUMMY_ICON, id);
            }
            item.setImage(id);
        }
    }
    //</WIN32 BUG>

    tm.update(true);
}

From source file:com.bdaum.zoom.ui.internal.views.PreviewView.java

License:Open Source License

private void setFilterButtonColor() {
    setFilterAction.setImageDescriptor(new ImageDescriptor() {
        @Override/*  ww  w  . j av  a2 s.  c  o  m*/
        public ImageData getImageData() {
            Display display = getSite().getShell().getDisplay();
            Image image = new Image(display, 16, 16);
            GC gc = new GC(image);
            gc.setBackground(display.getSystemColor(SWT.COLOR_DARK_GRAY));
            gc.fillRectangle(image.getBounds());
            Color color = new Color(display, filter);
            gc.setBackground(color);
            gc.fillOval(1, 1, 14, 14);
            ImageData data = image.getImageData();
            color.dispose();
            gc.dispose();
            image.dispose();
            return data;
        }
    });
}

From source file:com.google.gapid.image.Images.java

License:Apache License

public static org.eclipse.swt.graphics.Image createNonScaledImage(ResourceManager resources, ImageData data) {
    return resources.createImage(new ImageDescriptor() {
        @Override/*from  www  .  j  av  a 2 s.c  o m*/
        public org.eclipse.swt.graphics.Image createImage(boolean ignored, Device device) {
            return createNonScaledImage(device, data);
        }

        @Override
        public ImageData getImageData() {
            throw new AssertionError();
        }
    });
}

From source file:com.nokia.carbide.cpp.internal.ui.images.NullImageModel.java

License:Open Source License

public ImageDescriptor getImageDescriptor(Point size) throws CoreException {
    return new ImageDescriptor() {

        @Override/* w w w.jav  a 2  s  .  c om*/
        public ImageData getImageData() {
            return null;
        }

    };
}

From source file:de.fu_berlin.inf.dpp.ui.actions.LeaveSessionAction.java

License:Open Source License

public LeaveSessionAction() {
    setId(ACTION_ID);//from   w ww. j  a  va2 s .com
    setToolTipText(Messages.LeaveSessionAction_leave_session_tooltip);
    setImageDescriptor(new ImageDescriptor() {
        @Override
        public ImageData getImageData() {
            return ImageManager.ELCL_PROJECT_SHARE_LEAVE.getImageData();
        }
    });

    SarosPluginContext.initComponent(this);
    sessionManager.addSarosSessionListener(sessionListener);
    updateEnablement();
}

From source file:de.fu_berlin.inf.dpp.ui.actions.LeaveSessionAction.java

License:Open Source License

private void updateEnablement() {
    ISarosSession session = sessionManager.getSarosSession();

    if (session == null) {
        setEnabled(false);//  w w  w  . j  a  v a 2 s .c o  m
        return;
    }

    if (session.isHost()) {
        setToolTipText(Messages.LeaveSessionAction_stop_session_tooltip);
        setImageDescriptor(new ImageDescriptor() {
            @Override
            public ImageData getImageData() {
                return ImageManager.ELCL_PROJECT_SHARE_TERMINATE.getImageData();
            }
        });
    } else {
        setToolTipText(Messages.LeaveSessionAction_leave_session_tooltip);
        setImageDescriptor(new ImageDescriptor() {
            @Override
            public ImageData getImageData() {
                return ImageManager.ELCL_PROJECT_SHARE_LEAVE.getImageData();
            }
        });
    }
    setEnabled(true);
}

From source file:de.fu_berlin.inf.dpp.ui.actions.NewContactAction.java

License:Open Source License

public NewContactAction() {
    setId(ACTION_ID);//from w  w w.j  av  a2s .c o m
    setToolTipText(Messages.NewContactAction_tooltip);
    setImageDescriptor(new ImageDescriptor() {
        @Override
        public ImageData getImageData() {
            return ImageManager.ELCL_CONTACT_ADD.getImageData();
        }
    });

    SarosPluginContext.initComponent(this);

    sarosNet.addListener(connectionListener);
    setEnabled(sarosNet.isConnected());
}

From source file:es.cv.gvcase.fefem.action.loadresource.FilteredLoadResourceAction.java

License:Open Source License

private void setIconResource() {

    this.setImageDescriptor(new ImageDescriptor() {

        @Override// ww  w  . j a  v a2  s .c  o  m
        public ImageData getImageData() {
            String imagePath = "";
            try {
                imagePath = FileLocator
                        .toFileURL(Platform.getBundle(Activator.PLUGIN_ID).getResource("icons/full/etool16"))
                        .getPath();
                imagePath += "filteredloadresource.gif";
                Image image = new Image(Display.getCurrent(), imagePath);

                return image.getImageData();
            } catch (IOException e) {
            }

            return null;

        }

    });
}

From source file:eu.udig.catalog.ng.CatalogNGUIPlugin.java

License:Open Source License

/**
 * Create icon for provided resource, this will block!
 * /*w  ww . j  a  v  a2  s.  c  om*/
 * @param resource
 * @param monitor used to track progress in fetching an appropriate icon
 * @return ImageDescriptor for resource.
 * @throws IOException
 */
public static ImageDescriptor icon(final IResolve resolve, IProgressMonitor monitor) throws IOException {

    if (resolve.canResolve(ImageDescriptor.class)) {
        ImageDescriptor descriptor = resolve.resolve(ImageDescriptor.class, monitor);
        if (descriptor != null) {
            return descriptor;
        }
    }
    if (resolve instanceof IGeoResource) {
        ImageDescriptor icon = icon((IGeoResource) resolve, monitor);
        return icon != null ? icon : new ImageDescriptor() {

            public ImageData getImageData() {
                return image(resolve).getImageData();
            }

        };
    }

    if (resolve instanceof IService) {
        ImageDescriptor icon = icon((IService) resolve, monitor);
        if (icon != null) {
            return icon;
        }
        return CatalogNGUIPlugin.getDefault().getImageDescriptor(ISharedImages.SERVER_OBJ);
    }

    if (resolve instanceof IResolveFolder) {
        ImageDescriptor icon = icon((IResolveFolder) resolve, monitor);
        return icon != null ? icon
                : CatalogNGUIPlugin.getDefault().getImageDescriptor(ISharedImages.FOLDER_OBJ);
    }

    if (resolve instanceof ICatalog)
        return CatalogNGUIPlugin.getDefault().getImageDescriptor(ISharedImages.CATALOG_OBJ);

    return CatalogNGUIPlugin.getDefault().getImageDescriptor(ISharedImages.RESOURCE_OBJ);
}

From source file:hydrograph.ui.dataviewer.window.DebugDataViewer.java

License:Apache License

/**
 * Create the coolbar manager./*from  ww w . j a va 2 s.  c o m*/
 * 
 * @return the coolbar manager
 */
@Override
protected CoolBarManager createCoolBarManager(int style) {
    CoolBarManager coolBarManager = new CoolBarManager(style);

    actionFactory = new ActionFactory(this);

    ToolBarManager toolBarManager = new ToolBarManager();
    coolBarManager.add(toolBarManager);
    addtoolbarAction(toolBarManager, ImagePathConstant.DATA_VIEWER_EXPORT,
            actionFactory.getAction(ExportAction.class.getName()));

    /*
     * addtoolbarAction( toolBarManager, (XMLConfigUtil.CONFIG_FILES_PATH + ImagePathConstant.DATA_VIEWER_FIND),
     * actionFactory.getAction(FindAction.class.getName()));
     */
    addtoolbarAction(toolBarManager, ImagePathConstant.DATA_VIEWER_RELOAD,
            actionFactory.getAction(ReloadAction.class.getName()));
    /*
     * addtoolbarAction( toolBarManager, (XMLConfigUtil.CONFIG_FILES_PATH + ImagePathConstant.DATA_VIEWER_FILTER),
     * actionFactory.getAction(FilterAction.class.getName()));
     */
    addtoolbarAction(toolBarManager, ImagePathConstant.RESET_SORT,
            actionFactory.getAction(ResetSortAction.class.getName()));

    addtoolbarAction(toolBarManager, ImagePathConstant.TABLE_ICON,
            actionFactory.getAction(SelectColumnAction.class.getName()));

    addtoolbarAction(toolBarManager, ImagePathConstant.FIND_DATA,
            actionFactory.getAction(FindAction.class.getName()));

    addtoolbarAction(toolBarManager, ImagePathConstant.AUTO_ADJUST_COLUMNS,
            actionFactory.getAction(AutoExpandColumnsAction.class.getName()));

    dropDownAction = new Action("", SWT.DROP_DOWN) {
        @Override
        public void run() {
            tabFolder.showItem(tabFolder.getItem(0));
            tabFolder.setSelection(0);
        }
    };
    dropDownAction.setImageDescriptor(new ImageDescriptor() {

        @Override
        public ImageData getImageData() {
            return ImagePathConstant.DATA_VIEWER_SWITCH_VIEW.getImageFromRegistry().getImageData();
        }
    });

    dropDownAction.setMenuCreator(new ViewDataGridMenuCreator(actionFactory));
    toolBarManager.add(dropDownAction);

    return coolBarManager;
}