Dienstag, 27. März 2012

plug in your images revisited

this is a small refresh (small modifications) of "plug in your images" from here

go to your Activator
public class Activator extends AbstractUIPlugin
 and add/override the two following functions:

public static final String ToolbarIcon = "image.myimage";   
public static Image getImage(String imageId) {
        AbstractUIPlugin plugin = Activator.getDefault();
        ImageRegistry imageRegistry = plugin.getImageRegistry();
        return imageRegistry.get(imageId);
    }

    @Override
    protected void initializeImageRegistry(ImageRegistry registry) {
        super.initializeImageRegistry(registry);
        Bundle bundle = getBundle();

        ImageDescriptor myImage = ImageDescriptor.createFromURL(FileLocator
                .find(bundle, new Path("icons/toolbar_16.png"), null));
        registry.put(ToolbarIcon, myImage);
    }
now you can access the image  ToolbarIcon from your view simply by calling:
Activator.getImage(Activator.ToolbarIcon)


EXAMPLE OF YOUR ACTIVATOR:
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;

public class Activator extends AbstractUIPlugin {

    public static final String Icon32 = "image.icon32";
    private static Activator instance;
 
 
    public static Activator getDefault() {
        return instance;
    }

    public static Image getImage(String imageId) {
        AbstractUIPlugin plugin = Activator.getDefault();
        ImageRegistry imageRegistry = plugin.getImageRegistry();
        return imageRegistry.get(imageId);
    }

    @Override
    protected void initializeImageRegistry(ImageRegistry registry) {
        super.initializeImageRegistry(registry);
        load(registry, Icon32, "icons/icon.png");
    }
  
    private void load(ImageRegistry registry, String constant, String fileName) {
        ImageDescriptor icon = ImageDescriptor.createFromURL(FileLocator
                .find(getBundle(), new Path(fileName), null));
        registry.put(constant, icon);
    }

    public Activator() {
        instance = this;
    }
}

Montag, 13. Dezember 2010

getting the LOC (Lines Of Code) for your Eclipse Project?

  • Search -> File (CTRL+H)
  • Containing Text: \n
  • Check regular expressions checkbox
  • File name patterns: *.java
  • Create a working set that is appropriate or select your workspace

  • Click Search

at the top of the search window it will tell you the LOC as search results (and information about how many LOC for every class/package)

BRILLIANT!!

Mittwoch, 17. November 2010

are you crying out for an Eclipse visual editor?

Some time ago our company bought an license for instantiations windowbuilder pro (v6)
as we now upgraded to the latest eclipse version i noticed that instantiations no longer provides a download.
and horray! its gone freeware, as google bought the software up

you can access the files of WindowBuilder Pro (currently v8.1) here

got annoyed by searchin up and down your code to see method definitions?

go to emil crumhorn's webpage and download his awesome sourcehelper plugin

Eclipse is NOT showing Subversive's details on fresh install

if you want to show it by defaults
Go to "General" -> Appearance -> "Label Decorations" and check "SVN Project" decoration.

iff you want to configure it:
Go to "Team" -> "SVN" -> "Label Decorations" preferences.

Eclipse is showing only 'Generic' in Extensions -> RMB -> new

Window -> Preferences -> Plug-in Development -> Target Platform
and check running platform.

Maybe caused by: applied an target definition?