{
tpDesc = IDiagramConnectionDef.PROP_TOOL_PALETTE_DESCRIPTION.getLocalizationService().text(
tpDesc, CapitalizationType.TITLE_STYLE, false);
}
if (tpLabel != null) {
ToolEntry tool = new SapphireConnectionCreationToolEntry(tpLabel, tpDesc, factory, smallImage, largeImage);
DiagramPaletteDrawer drawer = getDiagramPaletteDrawer(drawers, connDef.getToolPaletteCompartment().content());
List<ToolEntry> list = entries.get(drawer.getId());
if (list == null) {
list = new ArrayList<ToolEntry>();
entries.put(drawer.getId(), list);
}
list.add(tool);
}
else
{
// TODO which case is this??
}
}
for (DiagramNodeTemplate nodeTemplate : nodeTemplates)
{
IDiagramNodeDef nodeDef = nodeTemplate.definition();
List<ImageData> imageDatas = nodeTemplate.getToolPaletteImages();
List<ImageDescriptor> imageDescriptors = new ArrayList<ImageDescriptor>();
for (ImageData imageData : imageDatas)
{
imageDescriptors.add(SwtUtil.toImageDescriptor(imageData));
}
ImageDescriptor smallImage = null;
ImageDescriptor largeImage = null;
if (imageDescriptors.size() == 1)
{
smallImage = largeImage = imageDescriptors.get(0);
}
else if (imageDescriptors.size() == 2)
{
org.eclipse.swt.graphics.ImageData id1 = imageDescriptors.get(0).getImageData();
org.eclipse.swt.graphics.ImageData id2 = imageDescriptors.get(1).getImageData();
if (id1.width > id2.width || id1.height > id2.height)
{
smallImage = imageDescriptors.get(1);
largeImage = imageDescriptors.get(0);
}
else
{
smallImage = imageDescriptors.get(0);
largeImage = imageDescriptors.get(1);
}
}
CreationFactory factory = new NodeCreationFactory(nodeTemplate);
String tpLabel = nodeDef.getToolPaletteLabel().content();
if (tpLabel != null)
{
tpLabel = IDiagramNodeDef.PROP_TOOL_PALETTE_LABEL.getLocalizationService().text(
tpLabel, CapitalizationType.TITLE_STYLE, false);
}
String tpDesc = nodeDef.getToolPaletteDescription().content();
if (tpDesc != null)
{
tpDesc = IDiagramNodeDef.PROP_TOOL_PALETTE_DESCRIPTION.getLocalizationService().text(
tpDesc, CapitalizationType.TITLE_STYLE, false);
}
ToolEntry tool = new CombinedTemplateCreationEntry(tpLabel, tpDesc, factory, smallImage, largeImage);
tool.setToolClass(CreationTool.class);
// find the right drawer
DiagramPaletteDrawer drawer = getDiagramPaletteDrawer(drawers, nodeDef.getToolPaletteCompartment().content());
List<ToolEntry> list = entries.get(drawer.getId());
if (list == null) {