本文整理汇总了Java中org.eclipse.jface.resource.ImageDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java ImageDescriptor类的具体用法?Java ImageDescriptor怎么用?Java ImageDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImageDescriptor类属于org.eclipse.jface.resource包,在下文中一共展示了ImageDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImageDescriptor
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
/**
* get icon based on item type (test/suite) and its status (pass/failed/exception/skip/in progress...)
*/
private ImageDescriptor getImageDescriptor(Object element) throws RuntimeException {
ImageDescriptor descriptor = null;
if (element instanceof Description == false) {
String msg = "Unknown type of element in tree of type " + element.getClass().getName();
Exception e = new RuntimeException(msg);
N4IDEXpectUIPlugin.logError("cannot obtain image descriptor, fallback to default", e);
return getImageDescriptor("n4_logo.png");
}
Description desc = (Description) element;
if (desc.isTest()) {
descriptor = getTestImageDescriptor(executionStatus.getStatus(desc));
} else if (desc.isSuite()) {
descriptor = getSuiteImageDescriptor(desc, executionStatus.getStatus(desc));
} else {
descriptor = getImageDescriptor("n4_logo.png");
}
return descriptor;
}
示例2: GraphicalPalette
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
public GraphicalPalette(){
PaletteDrawer tools=new PaletteDrawer("节点列表");
PanningSelectionToolEntry selectionTool=new PanningSelectionToolEntry();
tools.add(selectionTool);
this.setDefaultEntry(selectionTool);
ImageDescriptor transitionDescriptor=ImageDescriptor.createFromImage(Activator.getImageFromPlugin(Constants.TRANSITION_NODE_ICON_SMALL));
ConnectionCreationToolEntry connection=new ConnectionCreationToolEntry("Transition","Create a Transition",null,transitionDescriptor,transitionDescriptor);
tools.add(connection);
tools.add(this.createToolEntry(StartNode.class,"Start","Create a start node",70,40));
tools.add(this.createToolEntry(EndNode.class,"End","Create a end node",70,40));
tools.add(this.createToolEntry(TaskNode.class,"Task","Create a task node",80,40));
tools.add(this.createToolEntry(ForkNode.class,"Fork","Create a fork node",80,40));
tools.add(this.createToolEntry(JoinNode.class,"Join","Create a join node",80,40));
tools.add(this.createToolEntry(ForeachNode.class,"Foreach","Create a foreach node",80,40));
tools.add(this.createToolEntry(DecisionNode.class,"Decision","Create a decision node",80,40));
tools.add(this.createToolEntry(SubprocessNode.class,"Subprocess","Create a subprocess node",100,40));
tools.add(this.createToolEntry(EndCancelNode.class,"End Cancel","Create a end cancel node",100,40));
tools.add(this.createToolEntry(EndErrorNode.class,"End Error","Create a end error node",100,40));
tools.add(this.createToolEntry(StateNode.class,"State","Create a state node",80,40));
tools.add(this.createToolEntry(CustomNode.class,"Custom","Create a custom node",80,40));
this.add(tools);
}
示例3: decorate
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
@Override
public void decorate(final Object element, final IDecoration decoration) {
try {
if (element instanceof IProject) {
final URI uri = createPlatformResourceURI(((IProject) element).getName(), true);
final IN4JSProject project = core.findProject(uri).orNull();
if (null != project) {
final ImageRef imageRef = IMAGE_REF_CACHE.get(project.getProjectType());
if (null != imageRef) {
final ImageDescriptor descriptor = imageRef.asImageDescriptor().orNull();
if (null != descriptor) {
decoration.addOverlay(descriptor);
}
}
}
}
} catch (final Exception e) {
// Exception should not propagate from here, otherwise the lightweight decorator stops working once till
// next application startup.
LOGGER.error("Error while trying to get decorator for " + element, e);
}
}
示例4: createToolEntry
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
private CreationToolEntry createToolEntry(final Class<?> nodeClass,final String name,String desc,final int width,final int height){
SimpleFactory nodeFactory=new SimpleFactory(nodeClass){
@Override
public Object getNewObject() {
AbstractNodeElement node=instanceNode(nodeClass,name,width,height);
return node;
}
};
String nodeName=instanceNode(nodeClass,name,width,height).nodeName();
NodeImageConfig config=Activator.getPreference().getNodeImageConfigByName(nodeName);
if(config==null){
throw new RuntimeException("当前没有为名为"+nodeName+"的节点预定义配置信息!");
}
ImageDescriptor descriptor=ImageDescriptor.createFromImage(config.getSmallImage());
return new CombinedTemplateCreationEntry(name,desc,nodeFactory,descriptor,descriptor);
}
示例5: getImageDescriptor
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
public static ImageDescriptor getImageDescriptor(final String bundleID, final String path) {
assert bundleID != null : "No bundle defined";
assert path != null : "No path defined";
// if the bundle is not ready then there is no image
final Bundle bundle = Platform.getBundle(bundleID);
final int bundleState = bundle.getState();
if (bundleState != Bundle.ACTIVE && bundleState != Bundle.STARTING
&& bundleState != Bundle.RESOLVED) {
return null;
}
// look for the image (this will check both the plugin and fragment
// folders
final URL imagePath = FileLocator.find(bundle, new Path(path), null);
if (imagePath != null) {
return ImageDescriptor.createFromURL(imagePath);
}
return null;
}
示例6: createImageDescriptor
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
public static ImageDescriptor createImageDescriptor(String path, String pluginId) {
if (path == null) {
/* fall back if path null , so avoid NPE in eclipse framework */
return ImageDescriptor.getMissingImageDescriptor();
}
if (pluginId == null) {
/* fall back if pluginId null , so avoid NPE in eclipse framework */
return ImageDescriptor.getMissingImageDescriptor();
}
Bundle bundle = Platform.getBundle(pluginId);
if (bundle == null) {
/*
* fall back if bundle not available, so avoid NPE in eclipse
* framework
*/
return ImageDescriptor.getMissingImageDescriptor();
}
URL url = FileLocator.find(bundle, new Path(path), null);
ImageDescriptor imageDesc = ImageDescriptor.createFromURL(url);
return imageDesc;
}
示例7: getImage
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
/**
* Get image by path from image registry. If not already registered a new
* image will be created and registered. If not createable a fallback image
* is used instead
*
* @param path
* @param pluginId
* - plugin id to identify which plugin image should be loaded
* @return image
*/
public static Image getImage(String path, String pluginId) {
ImageRegistry imageRegistry = getImageRegistry();
if (imageRegistry == null) {
return null;
}
Image image = imageRegistry.get(path);
if (image == null) {
ImageDescriptor imageDesc = createImageDescriptor(path, pluginId);
image = imageDesc.createImage();
if (image == null) {
image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
}
imageRegistry.put(path, image);
}
return image;
}
示例8: updateItem
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
private void updateItem ( final StyledViewerLabel label, final DataItemEntry dataItemEntry )
{
String itemName = dataItemEntry.getName ();
if ( itemName == null || itemName.length () == 0 )
{
itemName = " ";
}
label.setText ( itemName );
if ( dataItemEntry.getIODirections ().containsAll ( Arrays.asList ( IODirection.INPUT, IODirection.OUTPUT ) ) )
{
label.setImage ( this.resource.createImage ( ImageDescriptor.createFromFile ( ConnectionLabelProvider.class, "icons/item_io.gif" ) ) );
}
else if ( dataItemEntry.getIODirections ().contains ( IODirection.INPUT ) )
{
label.setImage ( this.resource.createImage ( ImageDescriptor.createFromFile ( ConnectionLabelProvider.class, "icons/item_i.gif" ) ) );
}
else if ( dataItemEntry.getIODirections ().contains ( IODirection.OUTPUT ) )
{
label.setImage ( this.resource.createImage ( ImageDescriptor.createFromFile ( ConnectionLabelProvider.class, "icons/item_o.gif" ) ) );
}
else
{
label.setImage ( this.resource.createImage ( ImageDescriptor.createFromFile ( ConnectionLabelProvider.class, "icons/item.gif" ) ) );
}
}
示例9: getImageDescriptor
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
public static ImageDescriptor getImageDescriptor(final String bundleID, final String path) {
assert(bundleID != null) : "No bundle defined";
assert(path != null) : "No path defined";
// if the bundle is not ready then there is no image
final Bundle bundle = Platform.getBundle(bundleID);
final int bundleState = bundle.getState();
if ((bundleState != Bundle.ACTIVE) && (bundleState != Bundle.STARTING)
&& (bundleState != Bundle.RESOLVED)) {
return null;
}
// look for the image (this will check both the plugin and fragment
// folders
final URL imagePath = FileLocator.find(bundle, new Path(path), null);
if (imagePath != null) {
return ImageDescriptor.createFromURL(imagePath);
}
return null;
}
示例10: testDirectImageDescriptorCaching
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
/**
* Checks the direct {@link ImageDescriptor image descriptor} caching.
*/
@Test
public void testDirectImageDescriptorCaching() {
final ImageDescriptor desc1 = ImageRef.LIB_PATH.asImageDescriptor().orNull();
final ImageDescriptor desc2 = ImageRef.LIB_PATH.asImageDescriptor().orNull();
assertTrue("Expected exactly same reference of image descriptors.", desc1 == desc2);
}
示例11: decorate
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
@Override
public void decorate(Object resource, IDecoration decoration) {
int markers = MarkerFactory.findMarkers((IResource) resource).size();
if (markers > 0) {
decoration.addOverlay(ImageDescriptor.createFromFile(FileDecorator.class, ICON),
IDecoration.TOP_RIGHT);
decoration.setForegroundColor(color);
} else {
decoration.addOverlay(null);
decoration.setForegroundColor(new Color(null, 0, 0, 0, 0));
}
}
示例12: getSuiteImageDescriptor
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
/** obtain {@link ImageDescriptor} for suite} */
private ImageDescriptor getSuiteImageDescriptor(Description desc, ExecutionStatus st) {
ImageDescriptor descriptor;
switch (st) {
case PENDING:
descriptor = getImageDescriptor("testsuite.png");
break;
case STARTED:
descriptor = getImageDescriptor("testsuite_running.png");
break;
case IGNORED:
descriptor = getImageDescriptor("testsuite_ignored.png");
break;
case PASSED:
descriptor = getImageDescriptor("testsuite_pass.png");
Optional<XpectFileContentAccess> fileContentAccess = XpectFileContentsUtil
.getXpectFileContentAccess(desc);
if (fileContentAccess.isPresent()) {
if (fileContentAccess.get().containsFixme()) {
descriptor = getImageDescriptor("testsuite_fixme.png");
}
}
break;
case FAILED:
descriptor = getImageDescriptor("testsuite_fail.png");
break;
case ERROR:
descriptor = getImageDescriptor("testsuite_error.png");
break;
default:
descriptor = getImageDescriptor("n4_logo.png");
break;
}
return descriptor;
}
示例13: scheduleUpdateEditor
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
@Override
public void scheduleUpdateEditor(ImageDescriptor titleImageDescription) {
if (editor instanceof N4JSEditor && titleImageDescription != null) {
titleImageDescription = ((N4JSEditor) editor).applyTitleImageOverlays(titleImageDescription);
}
super.scheduleUpdateEditor(titleImageDescription);
}
示例14: createEObjectNode
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
/**
* Returns N4JSEObjectNode instead of simple EObjectNode to allow for attaching additional information such as
* inheritance state of members.
*/
@Override
public N4JSEObjectNode createEObjectNode(IOutlineNode parentNode, EObject modelElement,
ImageDescriptor imageDescriptor,
Object text,
boolean isLeaf) {
N4JSEObjectNode eObjectNode = new N4JSEObjectNode(modelElement, parentNode, imageDescriptor, text, isLeaf);
ICompositeNode parserNode = NodeModelUtils.getNode(modelElement);
if (parserNode != null)
eObjectNode.setTextRegion(parserNode.getTextRegion());
if (isLocalElement(parentNode, modelElement))
eObjectNode.setShortTextRegion(getLocationInFileProvider().getSignificantTextRegion(modelElement));
return eObjectNode;
}
示例15: getImageDescriptor
import org.eclipse.jface.resource.ImageDescriptor; //导入依赖的package包/类
@Override
public ImageDescriptor getImageDescriptor() {
if (getDisplayMode() == DisplayMode.WITH_COLUMNS) {
return AvroSchemaEditorActivator.getImageDescriptor(AvroSchemaEditorImages.WITH_COLUMNS_DISPLAY_MODE);
} else {
return AvroSchemaEditorActivator.getImageDescriptor(AvroSchemaEditorImages.WITHOUT_COLUMNS_DISPLAY_MODE);
}
}