| 1 | /******************************************************************************* |
|---|---|
| 2 | * Copyright (c) 2000, 2006 IBM Corporation and others. |
| 3 | * |
| 4 | * This program and the accompanying materials |
| 5 | * are made available under the terms of the Eclipse Public License 2.0 |
| 6 | * which accompanies this distribution, and is available at |
| 7 | * https://www.eclipse.org/legal/epl-2.0/ |
| 8 | * |
| 9 | * SPDX-License-Identifier: EPL-2.0 |
| 10 | * |
| 11 | * Contributors: |
| 12 | * IBM Corporation - initial API and implementation |
| 13 | *******************************************************************************/ |
| 14 | package org.eclipse.jdt.astview; |
| 15 | |
| 16 | import java.net.URL; |
| 17 | |
| 18 | import org.eclipse.core.runtime.FileLocator; |
| 19 | import org.eclipse.core.runtime.IPath; |
| 20 | import org.eclipse.core.runtime.Path; |
| 21 | |
| 22 | import org.eclipse.jface.action.IAction; |
| 23 | import org.eclipse.jface.resource.ImageDescriptor; |
| 24 | |
| 25 | import org.osgi.framework.Bundle; |
| 26 | |
| 27 | public class ASTViewImages { |
| 28 | |
| 29 | private static final IPath ICONS_PATH= new Path("$nl$/icons"); //$NON-NLS-1$ |
| 30 | |
| 31 | public static final String COLLAPSE= "collapseall.png"; //$NON-NLS-1$ |
| 32 | public static final String EXPAND= "expandall.png"; //$NON-NLS-1$ |
| 33 | public static final String LINK_WITH_EDITOR= "synced.png"; //$NON-NLS-1$ |
| 34 | |
| 35 | public static final String SETFOCUS= "setfocus.png"; //$NON-NLS-1$ |
| 36 | public static final String REFRESH= "refresh.png"; //$NON-NLS-1$ |
| 37 | public static final String CLEAR= "clear.png"; //$NON-NLS-1$ |
| 38 | |
| 39 | public static final String ADD_TO_TRAY= "add.png"; //$NON-NLS-1$ |
| 40 | |
| 41 | //---- Helper methods to access icons on the file system -------------------------------------- |
| 42 | |
| 43 | public static void setImageDescriptors(IAction action, String type) { |
| 44 | ImageDescriptor id= create("d", type); //$NON-NLS-1$ |
| 45 | if (id != null) |
| 46 | action.setDisabledImageDescriptor(id); |
| 47 | |
| 48 | id= create("e", type); //$NON-NLS-1$ |
| 49 | if (id != null) { |
| 50 | action.setHoverImageDescriptor(id); |
| 51 | action.setImageDescriptor(id); |
| 52 | } else { |
| 53 | action.setImageDescriptor(ImageDescriptor.getMissingImageDescriptor()); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | private static ImageDescriptor create(String prefix, String name) { |
| 58 | IPath path= ICONS_PATH.append(prefix).append(name); |
| 59 | return createImageDescriptor(ASTViewPlugin.getDefault().getBundle(), path); |
| 60 | } |
| 61 | |
| 62 | /* |
| 63 | * Since 3.1.1. Load from icon paths with $NL$ |
| 64 | */ |
| 65 | public static ImageDescriptor createImageDescriptor(Bundle bundle, IPath path) { |
| 66 | URL url= FileLocator.find(bundle, path, null); |
| 67 | if (url != null) { |
| 68 | return ImageDescriptor.createFromURL(url); |
| 69 | } |
| 70 | return null; |
| 71 | } |
| 72 | |
| 73 | private ASTViewImages() { |
| 74 | } |
| 75 | } |
| 76 |
Members