/** * {@inheritDoc} * * @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object) */ @Override public Image getImage(Object element) { Image result = null; if (columnIndex == 0 && diagramPart != null) { final DiagramEditPart diaEditPart = diagramPart.getDiagramEditPart(); final Object obj = diaEditPart.getModel(); if (obj instanceof View) { final EObject designerElement = ((View) obj).getElement(); if (designerElement instanceof DDiagram) { final List<Layer> activatedLayers = ((DDiagram) designerElement).getActivatedLayers(); Image img = null; if (EqualityHelper.contains(activatedLayers, (EObject) element)) { img = DiagramUIPlugin.getPlugin().getBundledImage(DiagramImagesPath.ACTIVE_LAYER_ICON); } else { img = DiagramUIPlugin.getPlugin().getBundledImage(DiagramImagesPath.INACTIVE_LAYER_ICON); } result = img; } } } else if (columnIndex == 1) { if (element instanceof Layer) { Layer layer = (Layer) element; if (!StringUtil.isEmpty(layer.getIcon())) { result = ImageProvider.getImageFromPath(layer.getIcon()); } } } return result; }
@Override protected Image getImage() { return DiagramUIPlugin.getPlugin() .getImage( DiagramUIPlugin.Implementation.getBundledImageDescriptor( DiagramImagesPath.DELETE_FROM_DIAGRAM_ICON)); }
/** * {@inheritDoc} * * @see * org.eclipse.sirius.ui.tools.api.properties.AbstractCompositeEObjectPropertySource#getItemProvidersAdapterFactory() */ @Override protected AdapterFactory getItemProvidersAdapterFactory() { AdapterFactory adapterFactory = null; final IEditorPart part = EclipseUIUtil.getActiveEditor(); if (part instanceof DDiagramEditor) { adapterFactory = ((DDiagramEditor) part).getAdapterFactory(); } else { adapterFactory = DiagramUIPlugin.getPlugin().getItemProvidersAdapterFactory(); } return adapterFactory; }
/** * Clear cache if necessary and return true if a refresh of figure of opened editors must be done, * false otherwise. * * @param delta , resource delta * @return boolean */ private boolean needClearCache(IResource resource) { boolean cacheUpdated = false; String resourceExtension = resource.getFileExtension(); if (WorkspaceImageFigure.isSvgImage(resourceExtension)) { String svgUri = resource.getFullPath().toString(); Option<String> removed = SVGWorkspaceImageFigure.removeFromCache(svgUri); if (removed.some()) { cacheUpdated = true; } } else { URL url; try { url = new File( ResourcesPlugin.getWorkspace() .getRoot() .getLocation() .append(resource.getFullPath()) .toOSString()) .toURI() .toURL(); } catch (MalformedURLException e) { DiagramPlugin.getDefault().logError("Invalid uri : " + e.getMessage()); return false; } ImageDescriptor bundledImageDescriptor = ImageDescriptor.createFromURL(url); boolean removed = DiagramUIPlugin.getPlugin().removeCacheImage(bundledImageDescriptor); // If a removed cache action is do, a refresh opened editors // is // required if (removed) { cacheUpdated = true; } } return cacheUpdated; }