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

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

Introduction

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

Prototype

public static ImageDescriptor createFromFile(Class<?> location, String filename) 

Source Link

Document

Creates and returns a new image descriptor from a file.

Usage

From source file:net.mldonkey.g2gui.view.resource.G2GuiResources.java

License:Open Source License

/**
 * @param filename//  w  ww. j  a  v a 2 s.  com
 * @return ImageDescriptor
 */
private static ImageDescriptor createRawImage(String filename) {
    return ImageDescriptor.createFromFile(MainWindow.class, imagesDirectory + filename);
}

From source file:net.refractions.udig.catalog.internal.wmt.ui.view.WMTZoomLevelSwitcher.java

License:Open Source License

/**
 * Creates the ImageRegistry and adds the two icons.
 *//*from  w w w . j  av  a2s  . c o  m*/
private void setUpImageCache(final Composite parent) {
    imageCache = new ImageRegistry(parent.getDisplay());

    ImageDescriptor descZoomOut = ImageDescriptor.createFromFile(getClass(), ICON_ZOOM_OUT_PATH);
    imageCache.put(ICON_ZOOM_OUT, descZoomOut);

    ImageDescriptor descZoomIn = ImageDescriptor.createFromFile(getClass(), ICON_ZOOM_IN_PATH);
    imageCache.put(ICON_ZOOM_IN, descZoomIn);
}

From source file:net.refractions.udig.catalog.internal.wmt.ui.wizard.controls.MQControl.java

License:Open Source License

@Override
protected Control buildControl(Composite composite) {
    Composite control = new Composite(composite, SWT.NONE);
    control.setLayout(new RowLayout(SWT.VERTICAL));

    Label text = new Label(control, SWT.HORIZONTAL | SWT.WRAP);
    text.setLayoutData(new RowData(400, 60));
    text.setText(Messages.Wizard_Mq_Info);

    Link link = new Link(control, SWT.BORDER);
    link.setText(Messages.Wizard_Mq_InfoLink);
    link.setLayoutData(new RowData(400, 60));
    link.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            Program.launch("http://developer.mapquest.com/Home/FreeTermsAndConditions"); //$NON-NLS-1$
        }/*ww  w . j a va 2 s  .c o m*/
    });

    imageCache = new ImageRegistry(composite.getDisplay());
    ImageDescriptor desc = ImageDescriptor.createFromFile(getClass(), MQControl.IMG_MQ);
    imageCache.put(MQControl.IMG_MQ, desc);

    Composite imgControl = new Composite(control, SWT.NONE);
    imgControl.setLayoutData(new RowData(300, 100));
    imgControl.setBackgroundImage(imageCache.get(MQControl.IMG_MQ));

    this.control = control;

    return control;
}

From source file:net.refractions.udig.catalog.internal.wmt.ui.wizard.controls.NASAControl.java

License:Open Source License

@Override
protected Control buildControl(Composite composite) {
    Composite control = new Composite(composite, SWT.NONE);
    control.setLayout(new RowLayout(SWT.VERTICAL));

    Label text = new Label(control, SWT.HORIZONTAL | SWT.WRAP);
    text.setLayoutData(new RowData(400, 60));
    text.setText(Messages.Wizard_Nasa_Info);

    Link link = new Link(control, SWT.BORDER);
    link.setText(Messages.Wizard_Nasa_InfoLink);
    link.setLayoutData(new RowData(400, 40));
    link.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            Program.launch("http://onearth.jpl.nasa.gov/tiled.html"); //$NON-NLS-1$
        }//from   w ww  . jav  a 2s . c om
    });

    imageCache = new ImageRegistry(composite.getDisplay());
    ImageDescriptor desc = ImageDescriptor.createFromFile(getClass(), NASAControl.IMG_NASA);
    imageCache.put(NASAControl.IMG_NASA, desc);

    Composite imgControl = new Composite(control, SWT.NONE);
    imgControl.setLayoutData(new RowData(300, 100));
    imgControl.setBackgroundImage(imageCache.get(NASAControl.IMG_NASA));

    this.control = control;

    return control;
}

From source file:net.refractions.udig.catalog.internal.wmt.ui.wizard.controls.OSMCloudMadeControl.java

License:Open Source License

@Override
protected Control buildControl(Composite infoBox) {
    display = infoBox.getDisplay();/* w  w  w  .j a  va  2  s . c o m*/
    Composite composite = new Composite(infoBox, SWT.NONE);
    composite.setLayout(new RowLayout(SWT.VERTICAL));

    //region Get Style From Groups
    btnStyleGroups = new Button(composite, SWT.RADIO);
    btnStyleGroups.setSelection(true);
    btnStyleGroups.setText(Messages.Wizard_CloudMade_StyleFromGroup);
    btnStyleGroups.addSelectionListener(radioSelectionListener);

    Composite compositeGroups = new Composite(composite, SWT.NONE);
    compositeGroups.setLayout(new RowLayout(SWT.HORIZONTAL));

    gBCloudMade = new Group(compositeGroups, SWT.BORDER);
    gBCloudMade.setLayout(new RowLayout(SWT.VERTICAL));
    gBCloudMade.setText(Messages.Wizard_CloudMade_GroupCloudMade);

    lvCloudMade = new ListViewer(gBCloudMade);
    lvCloudMade.getList().setLayoutData(new RowData(180, 80));
    lvCloudMade.setContentProvider(new ArrayContentProvider());
    lvCloudMade.setLabelProvider(new LabelProvider());

    gBCloudMade.pack();

    gBFeatured = new Group(compositeGroups, SWT.BORDER);
    gBFeatured.setLayout(new RowLayout(SWT.VERTICAL));
    gBFeatured.setText(Messages.Wizard_CloudMade_GroupFeatured);

    lvFeatured = new ListViewer(gBFeatured);
    lvFeatured.getList().setLayoutData(new RowData(180, 80));
    lvFeatured.setContentProvider(new ArrayContentProvider());
    lvFeatured.setLabelProvider(new LabelProvider());

    gBFeatured.pack();
    //endregion

    //region Get Style From Id
    Button btnOwnStyle = new Button(composite, SWT.RADIO);
    btnOwnStyle.setText(Messages.Wizard_CloudMade_StyleFromId);

    Composite compositeStyleId = new Composite(composite, SWT.NONE);
    compositeStyleId.setLayout(new RowLayout(SWT.HORIZONTAL));

    lblStyleIdField = new Label(compositeStyleId, SWT.HORIZONTAL);
    lblStyleIdField.setText(Messages.Wizard_CloudMade_StyleId);

    txtStyleId = new Text(compositeStyleId, SWT.BORDER);
    txtStyleId.setBounds(10, 10, 200, 200);
    txtStyleId.setText(Messages.Wizard_CloudMade_DefaultStyleId);

    txtStyleId.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent event) {
            if ((event.keyCode == SWT.CR) || (event.keyCode == SWT.KEYPAD_CR)) {
                updatePreview();
            }
        }

        public void keyReleased(KeyEvent arg0) {
        }
    });

    txtStyleId.addListener(SWT.Verify, new Listener() {
        public void handleEvent(Event e) {
            String input = e.text;
            for (int i = 0; i < input.length(); i++) {
                if (!('0' <= input.charAt(i) && input.charAt(i) <= '9')) {
                    e.doit = false;
                    return;
                }
            }
        }
    });

    btnRefresh = new Button(compositeStyleId, SWT.PUSH);
    btnRefresh.setText(Messages.Wizard_CloudMade_RefreshPreview);
    btnRefresh.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            updatePreview();
        }
    });

    link = new Link(composite, SWT.BORDER);
    link.setText(Messages.Wizard_CloudMade_StyleEditorInfo);
    link.setLayoutData(new RowData(400, 50));
    link.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            Program.launch("http://maps.cloudmade.com/editor"); //$NON-NLS-1$
        }
    });
    //endregion

    //region Preview
    Group gBPreview = new Group(composite, SWT.BORDER);
    gBPreview.setLayout(new RowLayout(SWT.HORIZONTAL));
    gBPreview.setText(Messages.Wizard_CloudMade_Preview);

    Composite compositeStyleInfo = new Composite(gBPreview, SWT.NONE);
    compositeStyleInfo.setLayout(new RowLayout(SWT.VERTICAL));
    compositeStyleInfo.setLayoutData(new RowData(180, 160));

    Label lblStyleName = new Label(compositeStyleInfo, SWT.HORIZONTAL | SWT.BOLD);
    lblStyleName.setText(Messages.Wizard_CloudMade_PreviewName);
    Font boldFont = JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT);
    lblStyleName.setFont(boldFont);

    lblStyleNameValue = new Label(compositeStyleInfo, SWT.HORIZONTAL);
    lblStyleNameValue.setText(""); //$NON-NLS-1$

    Label lblStyleId = new Label(compositeStyleInfo, SWT.HORIZONTAL);
    lblStyleId.setText(Messages.Wizard_CloudMade_PreviewId);
    lblStyleId.setFont(boldFont);

    lblStyleIdValue = new Label(compositeStyleInfo, SWT.HORIZONTAL);
    lblStyleIdValue.setText(""); //$NON-NLS-1$

    Label lblStyleAuthor = new Label(compositeStyleInfo, SWT.HORIZONTAL);
    lblStyleAuthor.setText(Messages.Wizard_CloudMade_PreviewAuthor);
    lblStyleAuthor.setFont(boldFont);

    lblStyleAuthorValue = new Label(compositeStyleInfo, SWT.HORIZONTAL);
    lblStyleAuthorValue.setText(""); //$NON-NLS-1$

    previewImage = new Composite(gBPreview, SWT.NONE);
    previewImage.setLayoutData(new RowData(233, 160));
    previewImage.setCursor(new Cursor(display, SWT.CURSOR_HAND));
    previewImage.setToolTipText(Messages.Wizard_CloudMade_PreviewGetFullMap);
    previewImage.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent arg0) {
        }

        public void mouseUp(MouseEvent arg0) {
        }

        public void mouseDown(MouseEvent arg0) {
            if (!previewStyleId.equals(OSMCloudMadeStylesManager.CloudMadeStyle.EMPTY_STYLE_ID)) {
                Program.launch("http://maps.cloudmade.com/?lat=51.508315&lng=-0.124712&zoom=14&styleId=" //$NON-NLS-1$
                        + previewStyleId);
            }
        }
    });

    gBPreview.pack();
    //endregion

    //region Load group styles
    stylesManager = new OSMCloudMadeStylesManager();

    // Group CloudMade
    styleGroupCloudMade = stylesManager.getGroupCloudMade();
    lvCloudMade.setInput(styleGroupCloudMade.getStyles());

    // Group Featured
    styleGroupFeatured = stylesManager.getGroupFeatured();
    lvFeatured.setInput(styleGroupFeatured.getStyles());

    // Select default style
    if (styleGroupCloudMade.getStyles().size() > 0) {
        lvCloudMade.getList().setSelection(0);
    }
    //endregion

    //region Set up image cache
    imageCache = new ImageRegistry(display);

    // load default image
    ImageDescriptor descDefault = ImageDescriptor.createFromFile(getClass(),
            OSMCloudMadeStylesManager.IMG_DEFAULT);
    imageCache.put(OSMCloudMadeStylesManager.CloudMadeStyle.EMPTY_STYLE_ID, descDefault);

    // load loading image
    ImageDescriptor descLoading = ImageDescriptor.createFromFile(getClass(),
            OSMCloudMadeStylesManager.IMG_LOADING);
    imageCache.put(OSMCloudMadeStylesManager.IMG_LOADING, descLoading);
    //endregion

    //region Set up listeners
    lvCloudMade.getList().addSelectionListener(listSelectionListener);
    lvFeatured.getList().addSelectionListener(listSelectionListener);
    radioSelectionListener.widgetSelected(null);
    //endregion

    serviceExtension = new WMTServiceExtension();

    control = composite;

    return composite;
}

From source file:net.refractions.udig.catalog.internal.wmt.ui.wizard.controls.OSMControl.java

License:Open Source License

@Override
protected Control buildControl(Composite composite) {
    Composite control = new Composite(composite, SWT.NONE);
    control.setLayout(new RowLayout(SWT.VERTICAL));

    Label text = new Label(control, SWT.HORIZONTAL | SWT.WRAP);
    text.setLayoutData(new RowData(400, 70));
    text.setText(Messages.Wizard_Osm_Info);

    Link link = new Link(control, SWT.BORDER);
    link.setText(Messages.Wizard_Osm_InfoLink);
    link.setLayoutData(new RowData(400, 40));
    link.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            Program.launch("http://www.openstreetmap.org/"); //$NON-NLS-1$
        }/*from  w w w .  j a v a  2s.  c o m*/
    });

    imageCache = new ImageRegistry(composite.getDisplay());
    ImageDescriptor desc = ImageDescriptor.createFromFile(getClass(), OSMControl.IMG_OSM);
    imageCache.put(OSMControl.IMG_OSM, desc);

    Composite imgControl = new Composite(control, SWT.NONE);
    imgControl.setLayoutData(new RowData(300, 100));
    imgControl.setBackgroundImage(imageCache.get(OSMControl.IMG_OSM));

    this.control = control;

    return control;
}

From source file:net.refractions.udig.catalog.internal.wmt.ui.wizard.controls.WWControl.java

License:Open Source License

@Override
protected Control buildControl(Composite composite) {
    Composite control = new Composite(composite, SWT.NONE);
    control.setLayout(new RowLayout(SWT.VERTICAL));

    Label text = new Label(control, SWT.HORIZONTAL | SWT.WRAP);
    text.setLayoutData(new RowData(400, 80));
    text.setText(Messages.Wizard_Ww_Example_Demis_Info);

    imageCache = new ImageRegistry(composite.getDisplay());
    ImageDescriptor desc = ImageDescriptor.createFromFile(getClass(), WWControl.IMG_DEMIS);
    imageCache.put(WWControl.IMG_DEMIS, desc);

    Composite imgControl = new Composite(control, SWT.NONE);
    imgControl.setLayoutData(new RowData(300, 100));
    imgControl.setBackgroundImage(imageCache.get(WWControl.IMG_DEMIS));

    Link link = new Link(control, SWT.BORDER);
    link.setText(Messages.Wizard_Ww_Example_Demis_Link);
    link.setLayoutData(new RowData(400, 40));
    link.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event event) {
            Program.launch(Messages.Wizard_Ww_Example_Demis_LinkUrl);
        }//from  w ww.  j av a2  s. c  o  m
    });

    this.control = control;

    return control;
}

From source file:net.sf.wickedshell.util.ResourceManager.java

License:Open Source License

/**
 * Returns an image descriptor stored in the file at the specified path
 * relative to the specified class./*from w w w .  ja  va 2s. c o  m*/
 * 
 * @param clazz
 *            Class The class relative to which to find the image descriptor
 * @param path
 *            String The path to the image file
 * @return ImageDescriptor The image descriptor stored in the file at the
 *         specified path
 */
@SuppressWarnings("unchecked")
public static ImageDescriptor getImageDescriptor(Class clazz, String path) {
    return ImageDescriptor.createFromFile(clazz, path);
}

From source file:net.sourceforge.appgen.editor.MappingDataEditor.java

License:Apache License

private void initImageRegistry() {
    imageRegistry = new ImageRegistry();

    String iconPath = "icon/";
    imageRegistry.put(CHECKED_IMAGE,//from w ww. j a  va 2  s  . c om
            ImageDescriptor.createFromFile(MappingDataEditor.class, iconPath + CHECKED_IMAGE + ".gif"));
    imageRegistry.put(UNCHECKED_IMAGE,
            ImageDescriptor.createFromFile(MappingDataEditor.class, iconPath + UNCHECKED_IMAGE + ".gif"));
}

From source file:no.hib.dpf.visualization.presentation.DPFVisualizationPaletteFactory.java

License:Open Source License

private void addDNodes(DGraph dgraph, EMap<DElement, VElement> maps) {
    ArrayList<DNode> paletteDNodes = getPaletteDNodes(dgraph.getDNodes(), maps);
    for (DNode dnode : paletteDNodes) {
        System.out.println("adding node: " + dnode);
        ImageDescriptor smallIcon = null;
        ImageDescriptor largeIcon = null;

        VElement element = VisualizationModelUtils.getVElement(dnode, maps);
        if (!VisualizationModelUtils.isVCompartmentElement(dnode, maps)) {
            if (element instanceof VNode) {
                VNode vNode = (VNode) element;
                smallIcon = vNode.getIcon() == null || vNode.getIcon().isEmpty() ? null
                        : ImageDescriptor.createFromFile(null, vNode.getIcon());
            }//w ww.  ja  v  a2 s  .com
            addDNodeToPalette(dnode, smallIcon, largeIcon);
        }
    }
}