Merge "Switch to newest Eclipse I-Build"
diff --git a/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/outline/GraphicsEditorOutlinePage.java b/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/outline/GraphicsEditorOutlinePage.java
index eba1f32..c7cfc28 100644
--- a/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/outline/GraphicsEditorOutlinePage.java
+++ b/examples/org.eclipse.graphiti.examples.common/src/org/eclipse/graphiti/examples/common/outline/GraphicsEditorOutlinePage.java
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * fvelasco - Bug 396247 - ImageDescriptor changes
*
* </copyright>
*
@@ -259,7 +260,9 @@
showPage(ID_OUTLINE);
}
};
- _showOutlineAction.setImageDescriptor(GraphitiUi.getImageService().getImageDescriptorForId(IExampleImageConstants.IMG_OUTLINE_TREE));
+ _showOutlineAction.setImageDescriptor(GraphitiUi.getImageService().getImageDescriptorForId(
+ "org.eclipse.graphiti.examples.tutorial.diagram.TutorialDiagramTypeProvider",
+ IExampleImageConstants.IMG_OUTLINE_TREE));
tbm.add(_showOutlineAction);
_showOverviewAction = new Action() {
@@ -269,6 +272,7 @@
}
};
_showOverviewAction.setImageDescriptor(GraphitiUi.getImageService().getImageDescriptorForId(
+ "org.eclipse.graphiti.examples.tutorial.diagram.TutorialDiagramTypeProvider",
IExampleImageConstants.IMG_OUTLINE_THUMBNAIL));
tbm.add(_showOverviewAction);
diff --git a/plugins/org.eclipse.graphiti.ui/.settings/.api_filters b/plugins/org.eclipse.graphiti.ui/.settings/.api_filters
index 5196660..9a4ea8b 100644
--- a/plugins/org.eclipse.graphiti.ui/.settings/.api_filters
+++ b/plugins/org.eclipse.graphiti.ui/.settings/.api_filters
@@ -130,6 +130,20 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/graphiti/ui/services/IImageService.java" type="org.eclipse.graphiti.ui.services.IImageService">
+ <filter id="405901410">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.services.IImageService"/>
+ <message_argument value="getImageDescriptorForId(String)"/>
+ </message_arguments>
+ </filter>
+ <filter id="405901410">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.ui.services.IImageService"/>
+ <message_argument value="getImageForId(String)"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/graphiti/ui/services/IUiLayoutService.java" type="org.eclipse.graphiti.ui.services.IUiLayoutService">
<filter id="571473929">
<message_arguments>
diff --git a/plugins/org.eclipse.graphiti.ui/schema/diagramTypeProviders.exsd b/plugins/org.eclipse.graphiti.ui/schema/diagramTypeProviders.exsd
index b3bcbad..23d651d 100644
--- a/plugins/org.eclipse.graphiti.ui/schema/diagramTypeProviders.exsd
+++ b/plugins/org.eclipse.graphiti.ui/schema/diagramTypeProviders.exsd
@@ -63,6 +63,9 @@
<documentation>
a unique name in the Eclipse environment that will be used to identify this diagram type provider
</documentation>
+ <appInfo>
+ <meta.attribute kind="identifier"/>
+ </appInfo>
</annotation>
</attribute>
<attribute name="name" type="string" use="required">
@@ -134,6 +137,7 @@
</appInfo>
<documentation>
Advertises that the containing diagram type provider needs the given image provider for rendering purposes.
+You can also use the <samp>'org.eclipse.graphiti.ui.imageProvider'</samp> extension point instead, pointing it to the <samp>diagramTypeProvider</samp> it provides images for.
</documentation>
</annotation>
<complexType>
diff --git a/plugins/org.eclipse.graphiti.ui/schema/imageProviders.exsd b/plugins/org.eclipse.graphiti.ui/schema/imageProviders.exsd
index 160298e..df09cee 100644
--- a/plugins/org.eclipse.graphiti.ui/schema/imageProviders.exsd
+++ b/plugins/org.eclipse.graphiti.ui/schema/imageProviders.exsd
@@ -1,128 +1,151 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.graphiti.ui" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.graphiti.ui" id="imageProviders" name="Image Providers"/>
- </appInfo>
- <documentation>
- Customers of Graphiti can use this extension point to register their own image providers.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="imageProvider" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="imageProvider">
- <annotation>
- <appInfo>
- <meta.element labelAttribute="id"/>
- </appInfo>
- </annotation>
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- a unique name in the NWDS environment that will be used to identify this image provider
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- the name of a class that implements <samp>org.eclipse.graphiti.ui.platform.IImageProvider</samp>.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.eclipse.graphiti.ui.platform.AbstractImageProvider:org.eclipse.graphiti.ui.platform.IImageProvider"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- <p>
-<pre>
- <extension
- point="org.eclipse.graphiti.ui.imageProviders">
- <imageProvider
- id="org.eclipse.graphiti.examples.common.SampleImageProvider">
- </imageProvider>
- </extension>
-</pre>
-</p>
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- Instead of implementing the interface <samp>org.eclipse.graphiti.ui.platform.IImageProvider</samp> directly, the customer should extend the base class <samp>org.eclipse.graphiti.ui.platform.AbstractImageProvider</samp>.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 0.7.0
- </documentation>
- </annotation>
-
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2005, 2010 SAP AG.<br>
-All rights reserved. This program and the accompanying materials are made
-available under the terms of the Eclipse Public License v1.0 which accompanies
-this distribution, and is available at <a
-href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
-
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.graphiti.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.graphiti.ui" id="imageProviders" name="Image Providers"/>
+ </appInfo>
+ <documentation>
+ Customers of Graphiti can use this extension point to register their own image providers.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="imageProvider" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="imageProvider">
+ <annotation>
+ <appInfo>
+ <meta.element labelAttribute="id" deprecated="true"/>
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ <element ref="diagramTypeProvider"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ a unique name in the NWDS environment that will be used to identify this image provider
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the name of a class that implements <samp>org.eclipse.graphiti.ui.platform.IImageProvider</samp>.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.graphiti.ui.platform.AbstractImageProvider:org.eclipse.graphiti.ui.platform.IImageProvider"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="diagramTypeProvider">
+ <annotation>
+ <documentation>
+ Referred diagram type provider. This makes the image provider available for the referenced diagram type provider. Advertises that the containing diagram type provider needs the given image provider for rendering purposes.
+You can also use the <samp>'org.eclipse.graphiti.ui.diagramTypeProvider'</samp> extension point instead, pointing it to the <samp>ImageProvider</samp> its images it requires.
+ </documentation>
+ </annotation>
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ the diagram type provider identifier. This is an ID defined by the 'org.eclipse.graphiti.ui.diagramTypeProviders' extension point.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.graphiti.ui.diagramTypeProviders/diagramTypeProvider/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ <p>
+<pre>
+ <extension
+ point="org.eclipse.graphiti.ui.imageProviders">
+ <imageProvider
+ id="org.eclipse.graphiti.examples.common.SampleImageProvider">
+ </imageProvider>
+ </extension>
+</pre>
+</p>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ Instead of implementing the interface <samp>org.eclipse.graphiti.ui.platform.IImageProvider</samp> directly, the customer should extend the base class <samp>org.eclipse.graphiti.ui.platform.AbstractImageProvider</samp>.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 0.7.0
+ </documentation>
+ </annotation>
+
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2005, 2010 SAP AG.<br>
+All rights reserved. This program and the accompanying materials are made
+available under the terms of the Eclipse Public License v1.0 which accompanies
+this distribution, and is available at <a
+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorActionBarContributor.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorActionBarContributor.java
index 6ddeee3..4ae3216 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorActionBarContributor.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorActionBarContributor.java
@@ -14,6 +14,7 @@
* mwenz - Fixed NPE in RCP usecase
* Felix Velasco (mwenz) - Bug 323351 - Enable to suppress/reactivate the speed buttons
* mwenz - Bug 381437 - IllegalArgumentException when edit menu missing
+ * fvelasco - Bug 396247 - ImageDescriptor changes
*
* </copyright>
*
@@ -95,18 +96,18 @@
// shall be shown or not
RetargetAction toggleContextPadAction = new RetargetAction(ToggleContextButtonPadAction.ACTION_ID,
ToggleContextButtonPadAction.TEXT, IAction.AS_CHECK_BOX);
- toggleContextPadAction.setImageDescriptor(GraphitiUi.getImageService().getImageDescriptorForId(
+ toggleContextPadAction.setImageDescriptor(GraphitiUi.getImageService().getPlatformImageDescriptorForId(
IPlatformImageConstants.IMG_TOGGLE_PAD));
addRetargetAction(toggleContextPadAction);
// End bug 323351
RetargetAction removeRetargetAction = new RetargetAction(RemoveAction.ACTION_ID, RemoveAction.TEXT);
- removeRetargetAction.setImageDescriptor(GraphitiUi.getImageService().getImageDescriptorForId(
+ removeRetargetAction.setImageDescriptor(GraphitiUi.getImageService().getPlatformImageDescriptorForId(
IPlatformImageConstants.IMG_EDIT_REMOVE));
removeRetargetAction.setActionDefinitionId(RemoveAction.ACTION_DEFINITION_ID);
addRetargetAction(removeRetargetAction);
RetargetAction updateRetargetAction = new RetargetAction(UpdateAction.ACTION_ID, UpdateAction.TEXT);
- updateRetargetAction.setImageDescriptor(GraphitiUi.getImageService().getImageDescriptorForId(
+ updateRetargetAction.setImageDescriptor(GraphitiUi.getImageService().getPlatformImageDescriptorForId(
IPlatformImageConstants.IMG_EDIT_REFRESH));
updateRetargetAction.setActionDefinitionId(UpdateAction.ACTION_DEFINITION_ID);
addRetargetAction(updateRetargetAction);
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorContextMenuProvider.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorContextMenuProvider.java
index 6097e4e..b77f3f3 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorContextMenuProvider.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/editor/DiagramEditorContextMenuProvider.java
@@ -15,6 +15,7 @@
* Bug 336488 - DiagramEditor API
* Benjamin Schmeling - mwenz - Bug 367483 - Support composite connections
* cbrand - Bug 377783 - Dump for figures in connection layer needed
+ * fvelasco - Bug 396247 - ImageDescriptor changes
*
* </copyright>
*
@@ -241,7 +242,8 @@
}
action.setText(text);
action.setDescription(cmEntry.getDescription());
- ImageDescriptor image = GraphitiUi.getImageService().getImageDescriptorForId(cmEntry.getIconId());
+ ImageDescriptor image = GraphitiUi.getImageService().getImageDescriptorForId(
+ diagramTypeProvider.getProviderId(), cmEntry.getIconId());
action.setImageDescriptor(image);
appendContributionItem(manager, groupID, new ActionContributionItem(action));
}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/features/AbstractDrillDownFeature.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/features/AbstractDrillDownFeature.java
index 9510bfe..2165372 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/features/AbstractDrillDownFeature.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/features/AbstractDrillDownFeature.java
@@ -14,6 +14,7 @@
* Ali Akar, mwenz - Bug 340842 - Opening a user contributed editor
* Bug 336488 - DiagramEditor API
* cbrand - Bug 377475 - Fix AbstractCustomFeature.execute and canExecute
+ * fvelasco - Bug 396247 - ImageDescriptor changes
*
* </copyright>
*
@@ -231,7 +232,8 @@
@Override
public Image getImage(Object element) {
if (this.image == null) {
- this.image = GraphitiUi.getImageService().getImageForId(IPlatformImageConstants.IMG_DIAGRAM);
+ this.image = GraphitiUi.getImageService().getPlatformImageForId(
+ IPlatformImageConstants.IMG_DIAGRAM);
}
return this.image;
}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/command/CreateConnectionCommand.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/command/CreateConnectionCommand.java
index caade76..16753ab 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/command/CreateConnectionCommand.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/command/CreateConnectionCommand.java
@@ -15,6 +15,7 @@
* mwenz - Bug 340627 - Features should be able to indicate cancellation
* mgorning - Bug 329517 - state call backs during creation of a connection
* Bug 336488 - DiagramEditor API
+ * fvelasco - Bug 396247 - ImageDescriptor changes
*
* </copyright>
*
@@ -341,10 +342,12 @@
GenericFeatureCommandWithContext command = (GenericFeatureCommandWithContext) element;
IFeature feature = command.getFeature();
+ String providerId = feature.getFeatureProvider().getDiagramTypeProvider().getProviderId();
if (feature instanceof ICreateInfo) // e.g. ICreateConnectionFeature
- return GraphitiUi.getImageService().getImageForId(((ICreateInfo) feature).getCreateImageId());
+ return GraphitiUi.getImageService().getImageForId(providerId,
+ ((ICreateInfo) feature).getCreateImageId());
if (feature instanceof ICustomFeature)
- return GraphitiUi.getImageService().getImageForId(((ICustomFeature) feature).getImageId());
+ return GraphitiUi.getImageService().getImageForId(providerId, ((ICustomFeature) feature).getImageId());
return null;
}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButton.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButton.java
index 9d272b1..ddb86a8 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButton.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButton.java
@@ -12,6 +12,7 @@
* Bug 336488 - DiagramEditor API
* mwenz - Bug 373298 - Possible Resource leaks in Graphiti
* mwenz - Bug 389379 - Editor Dirty Handling (gets broken after context button execution)
+ * fvelasco - Bug 396247 - ImageDescriptor changes
*
* </copyright>
*
@@ -109,6 +110,8 @@
*/
private MouseListener mouseDragUpListener;
+ private String providerId;
+
// ============================ inner classes =============================
/**
@@ -123,7 +126,7 @@
@Override
public Image getImage(Object element) {
- return GraphitiUi.getImageService().getImageForId(((ContextButtonEntry) element).getIconId());
+ return GraphitiUi.getImageService().getImageForId(providerId, ((ContextButtonEntry) element).getIconId());
}
};
@@ -132,6 +135,8 @@
/**
* Creates a new ContextButton.
*
+ * @param providerId
+ *
* @param positionedContextButton
* The {@link PositionedContextButton} contains the visual
* information for the context button (colors, position, size,
@@ -141,10 +146,12 @@
* The {@link ContextButtonPad} is used to access the environment
* (editor, ...).
*/
- public ContextButton(PositionedContextButton positionedContextButton, ContextButtonPad contextButtonPad) {
+ public ContextButton(String providerId, PositionedContextButton positionedContextButton,
+ ContextButtonPad contextButtonPad) {
this.positionedContextButton = positionedContextButton;
this.contextButtonPad = contextButtonPad;
this.contextButtonEntry = (ContextButtonEntry) positionedContextButton.getContextButtonEntry();
+ this.providerId = providerId;
setBorder(null); // get rid of default border
setTransparencyProvider(contextButtonPad);
@@ -329,7 +336,7 @@
// create image
String iconId = getEntry().getIconId();
- Image originalImage = GraphitiUi.getImageService().getImageForId(iconId);
+ Image originalImage = GraphitiUi.getImageService().getImageForId(providerId, iconId);
Image image;
if (!isEnabled()) {
image = new Image(originalImage.getDevice(), originalImage, SWT.IMAGE_DISABLE);
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButtonPad.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButtonPad.java
index 2431d25..88a54ac 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButtonPad.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/contextbuttons/ContextButtonPad.java
@@ -11,6 +11,7 @@
* SAP AG - initial API, implementation and documentation
* Bug 336488 - DiagramEditor API
* mwenz - Bug 373298 - Possible Resource leaks in Graphiti
+ * fvelasco - Bug 396247 - ImageDescriptor changes
*
* </copyright>
*
@@ -290,7 +291,8 @@
Rectangle position = transformGenericRectangle(positionedButton.getPosition(), 0);
// translate position relative to bounds (after the bounds are set!)
position.translate(-getBounds().getTopLeft().x, -getBounds().getTopLeft().y);
- ContextButton cb = new ContextButton(positionedButton, this);
+ ContextButton cb = new ContextButton(editor.getDiagramTypeProvider().getProviderId(), positionedButton,
+ this);
add(cb, position);
}
}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFPaletteRoot.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFPaletteRoot.java
index 14b5991..c6470b4 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFPaletteRoot.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/editor/GFPaletteRoot.java
@@ -11,6 +11,7 @@
* SAP AG - initial API, implementation and documentation
* mwenz - Bug 341224: Allow to hide the selection and marquee tools in the palette
* Bug 336488 - DiagramEditor API
+ * fvelasco - Bug 396247 - ImageDescriptor changes
*
* </copyright>
*
@@ -124,7 +125,8 @@
} else if (toolEntry instanceof IStackToolEntry) {
IStackToolEntry stackToolEntry = (IStackToolEntry) toolEntry;
PaletteStack stack = new PaletteStack(stackToolEntry.getLabel(), stackToolEntry.getDescription(),
- GraphitiUi.getImageService().getImageDescriptorForId(stackToolEntry.getIconId()));
+ GraphitiUi.getImageService().getImageDescriptorForId(diagramTypeProvider.getProviderId(),
+ stackToolEntry.getIconId()));
drawer.add(stack);
List<ICreationToolEntry> creationToolEntries = stackToolEntry.getCreationToolEntries();
for (ICreationToolEntry creationToolEntry : creationToolEntries) {
@@ -237,7 +239,8 @@
imageDescriptor = ((IEclipseImageDescriptor) creationToolEntry).getImageDescriptor();
} else {
String iconId = (smallImage) ? creationToolEntry.getIconId() : creationToolEntry.getLargeIconId();
- imageDescriptor = GraphitiUi.getImageService().getImageDescriptorForId(iconId);
+ imageDescriptor = GraphitiUi.getImageService().getImageDescriptorForId(diagramTypeProvider.getProviderId(),
+ iconId);
}
return imageDescriptor;
}
@@ -247,7 +250,8 @@
if (compartmentEntry instanceof IEclipseImageDescriptor) {
imageDescriptor = ((IEclipseImageDescriptor) compartmentEntry).getImageDescriptor();
} else {
- imageDescriptor = GraphitiUi.getImageService().getImageDescriptorForId(compartmentEntry.getIconId());
+ imageDescriptor = GraphitiUi.getImageService().getImageDescriptorForId(diagramTypeProvider.getProviderId(),
+ compartmentEntry.getIconId());
}
return imageDescriptor;
}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java
index 756a5b6..dd6e920 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/parts/PictogramElementDelegate.java
@@ -20,6 +20,7 @@
* mwenz - Bug 341898 - Support for AdvancedPropertySheet
* mwenz - Bug 358255 - Add Border/Background decorators
* mgorning - Bug 368124 - ConnectionDecorator with Text causes problems
+ * fvelasco - Bug 396247 - ImageDescriptor changes
*
* </copyright>
*
@@ -581,7 +582,8 @@
} else if (graphicsAlgorithm instanceof Image && figure instanceof ImageFigure) {
ImageFigure imageFigure = (ImageFigure) figure;
Image pictogramImage = (Image) graphicsAlgorithm;
- org.eclipse.swt.graphics.Image image = GraphitiUi.getImageService().getImageForId(pictogramImage.getId());
+ org.eclipse.swt.graphics.Image image = GraphitiUi.getImageService().getImageForId(
+ configurationProvider.getDiagramTypeProvider().getProviderId(), pictogramImage.getId());
imageFigure.setImage(image);
imageFigure.setAlignment(PositionConstants.CENTER);
imageFigure.setOpaque(false);
@@ -934,6 +936,7 @@
if (decorator instanceof IImageDecorator) {
IImageDecorator imageDecorator = (IImageDecorator) decorator;
org.eclipse.swt.graphics.Image imageForId = GraphitiUi.getImageService().getImageForId(
+ configurationProvider.getDiagramTypeProvider().getProviderId(),
imageDecorator.getImageId());
ImageFigure imageFigure = new DecoratorImageFigure(imageForId);
decoratorFigure = imageFigure;
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/platform/ExtensionManager.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/platform/ExtensionManager.java
index 129bb71..deab64e 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/platform/ExtensionManager.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/platform/ExtensionManager.java
@@ -11,15 +11,20 @@
* SAP AG - initial API, implementation and documentation
* mwenz - Bug 352709 - invalid image provider id crashes diagram editor
* fvelasco - Bug 323349 - Enable external invocation of features
+ * fvelasco - Bug 396247 - ImageDescriptor changes
* </copyright>
*
*******************************************************************************/
package org.eclipse.graphiti.ui.internal.platform;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
@@ -65,6 +70,8 @@
private static final String EP_CHILD_NODE_DIAGRAM_TYPE = "diagramType"; //$NON-NLS-1$
+ private static final String EP_CHILD_NODE_DIAGRAM_TYPE_PROVIDER = "diagramTypeProvider"; //$NON-NLS-1$
+
private static final String EP_ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
private static final String EP_ATTRIBUTE_ID = "id"; //$NON-NLS-1$
@@ -83,11 +90,16 @@
private IImageProvider imageProviders[] = null;
+ private IImageProvider platformImageProvider = null;
+
+ private Map<String, Set<IImageProvider>> dtp2imageProvider = null;
+
/**
*
*/
private ExtensionManager() {
super();
+ dtp2imageProvider = new HashMap<String, Set<IImageProvider>>();
searchForExtensions();
}
@@ -203,7 +215,7 @@
imageProviders = new IImageProvider[0];
// load image providers from the framework
- loadImageProvider(PlatformImageProvider.ID);
+ platformImageProvider = loadImageProvider(PlatformImageProvider.ID);
}
public IDiagramTypeProvider createDiagramTypeProvider(String providerId) {
@@ -233,7 +245,7 @@
context = DiagramEditor.DIAGRAM_CONTEXT_ID;
}
if (name != null) {
- // read references to image extensions and try to
+ // read direct references to image extensions and try to
// instantiate image provider
IConfigurationElement[] children = element.getChildren();
for (int k = 0; k < children.length; k++) {
@@ -242,11 +254,13 @@
String childExtensionId = childElement.getAttribute(EP_ATTRIBUTE_ID);
if (childName != null && childExtensionId != null) {
if (EP_CHILD_NODE_IMAGE_PROVIDER.equals(childName)) {
- boolean ret = loadImageProvider(childExtensionId);
- if (ret == false) {
+ IImageProvider imageProvider = loadImageProvider(childExtensionId);
+ if (imageProvider == null) {
IllegalArgumentException e = new IllegalArgumentException("A Graphiti image provider with id '" //$NON-NLS-1$
+ childExtensionId + "' could not be found"); //$NON-NLS-1$
T.racer().error("Error while creating the children for '" + providerId + "'", e); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ registerImageProviderForDiagramTypeProvider(providerId, imageProvider);
}
}
}
@@ -263,18 +277,47 @@
}
} catch (CoreException e) {
// $JL-EXC$
- T.racer().error("Unable to create DiagramTypeProcider class", e);
+ T.racer().error("Unable to create DiagramTypeProvider class", e);
}
}
}
}
}
+ IExtensionPoint imageProviderExtensionPoint = extensionRegistry.getExtensionPoint(EP_IMAGE_PROVIDERS);
+ // read image providers that point back to this diagramTypeProvider
+ for (IExtension extension : imageProviderExtensionPoint.getExtensions()) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (int j = 0; j < configurationElements.length; j++) {
+ IConfigurationElement element = configurationElements[j];
+ String imageProviderId = element.getAttribute(EP_ATTRIBUTE_ID);
+
+ IConfigurationElement[] children = element.getChildren(EP_CHILD_NODE_DIAGRAM_TYPE_PROVIDER);
+
+ for (IConfigurationElement child : children) {
+ String referredDiagramTypeProviderId = child.getAttribute(EP_ATTRIBUTE_ID);
+ if (providerId.equals(referredDiagramTypeProviderId)) {
+ IImageProvider imageProvider = loadImageProvider(imageProviderId);
+ registerImageProviderForDiagramTypeProvider(providerId, imageProvider);
+ break;
+ }
+ }
+ }
+ }
+
return diagramTypeProvider;
}
- public IImageProvider[] getImageProviders() {
- return imageProviders;
+ public IImageProvider getPlatformImageProvider() {
+ return platformImageProvider;
+ }
+
+ public Collection<IImageProvider> getImageProvidersForDiagramTypeProviderId(String providerId) {
+ Collection<IImageProvider> providers = dtp2imageProvider.get(providerId);
+ if (providers == null)
+ return Collections.singleton(platformImageProvider);
+ else
+ return providers;
}
public IDiagramType[] getDiagramTypes() {
@@ -294,17 +337,16 @@
return null;
}
- private boolean loadImageProvider(String providerId) {
+ private IImageProvider loadImageProvider(String imageProviderId) {
// check whether the image provider is already loaded
- IImageProvider providers[] = getImageProviders();
- for (int i = 0; i < providers.length; i++) {
- IImageProvider provider = providers[i];
- if (providerId.equals(provider.getProviderId())) {
- return true;
+ for (int i = 0; i < imageProviders.length; i++) {
+ IImageProvider provider = imageProviders[i];
+ if (imageProviderId.equals(provider.getProviderId())) {
+ return provider;
}
}
- IImageProvider newProvider = createImageProvider(providerId);
+ IImageProvider newProvider = createImageProvider(imageProviderId);
if (newProvider != null) {
// extend current list of image providers
@@ -313,10 +355,10 @@
imageProvidersDest[imageProviders.length] = newProvider;
imageProviders = imageProvidersDest;
- return true;
+ return newProvider;
}
- return false;
+ return null;
}
private List<IDiagramType> createDiagramTypes() {
@@ -389,6 +431,17 @@
return null;
}
+ private void registerImageProviderForDiagramTypeProvider(String providerId, IImageProvider imageProvider) {
+ Set<IImageProvider> providers = dtp2imageProvider.get(providerId);
+ if (providers == null) {
+ providers = new HashSet<IImageProvider>();
+ dtp2imageProvider.put(providerId, providers);
+ providers.add(platformImageProvider);
+ }
+
+ providers.add(imageProvider);
+ }
+
public IFeatureProvider createFeatureProvider(Diagram diagram) {
Assert.isNotNull(diagram);
String providerId = getDiagramTypeProviderId(diagram.getDiagramTypeId());
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/ImageService.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/ImageService.java
index af22309..1619f7e 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/ImageService.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/services/impl/ImageService.java
@@ -9,15 +9,19 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * fvelasco - Bug 396247 - ImageDescriptor changes
*
* </copyright>
*
*******************************************************************************/
package org.eclipse.graphiti.ui.internal.services.impl;
+import java.util.Collection;
+
import org.eclipse.graphiti.ui.internal.GraphitiUIPlugin;
import org.eclipse.graphiti.ui.internal.platform.ExtensionManager;
import org.eclipse.graphiti.ui.platform.IImageProvider;
+import org.eclipse.graphiti.ui.platform.PlatformImageProvider;
import org.eclipse.graphiti.ui.services.IImageService;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
@@ -31,35 +35,37 @@
*/
public class ImageService implements IImageService {
- public ImageDescriptor getImageDescriptorForId(String imageId) {
+ public ImageDescriptor getImageDescriptorForId(String providerId, String imageId) {
- if (imageId == null)
+ if (imageId == null || providerId == null)
return null;
+ String registryKey = makeKey(providerId, imageId);
ImageRegistry imageRegistry = GraphitiUIPlugin.getDefault().getImageRegistry();
- ImageDescriptor imageDescriptor = imageRegistry.getDescriptor(imageId);
+ ImageDescriptor imageDescriptor = imageRegistry.getDescriptor(registryKey);
if (imageDescriptor != null) {
return imageDescriptor;
}
- imageDescriptor = createImageDescriptorForId(imageId);
+ imageDescriptor = createImageDescriptorForId(providerId, imageId);
return imageDescriptor;
}
- public Image getImageForId(String imageId) {
+ public Image getImageForId(String providerId, String imageId) {
- if (imageId == null)
+ if (imageId == null || providerId == null)
return null;
+ String registryKey = makeKey(providerId, imageId);
// if image already available take it
ImageRegistry imageRegistry = GraphitiUIPlugin.getDefault().getImageRegistry();
- Image result = imageRegistry.get(imageId);
+ Image result = imageRegistry.get(registryKey);
if (result != null && !result.isDisposed()) {
return result;
}
- createImageDescriptorForId(imageId);
- Image image = imageRegistry.get(imageId); // now there is an image
+ createImageDescriptorForId(providerId, imageId);
+ Image image = imageRegistry.get(registryKey); // now there is an image
// registered
if (image == null) {
throw new IllegalStateException("No image could be retrieved for imageId '" + imageId + "'"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -72,6 +78,42 @@
imageRegistry.remove(key);
}
+ public ImageDescriptor getPlatformImageDescriptorForId(String imageId) {
+ if (imageId == null)
+ return null;
+
+ String registryKey = makePlatformKey(imageId);
+ ImageRegistry imageRegistry = GraphitiUIPlugin.getDefault().getImageRegistry();
+ ImageDescriptor imageDescriptor = imageRegistry.getDescriptor(registryKey);
+ if (imageDescriptor != null) {
+ return imageDescriptor;
+ }
+
+ imageDescriptor = createPlatformImageDescriptorForId(imageId);
+ return imageDescriptor;
+ }
+
+ public Image getPlatformImageForId(String imageId) {
+ if (imageId == null)
+ return null;
+
+ String registryKey = makePlatformKey(imageId);
+ // if image already available take it
+ ImageRegistry imageRegistry = GraphitiUIPlugin.getDefault().getImageRegistry();
+ Image result = imageRegistry.get(registryKey);
+ if (result != null && !result.isDisposed()) {
+ return result;
+ }
+
+ createPlatformImageDescriptorForId(imageId);
+ Image image = imageRegistry.get(registryKey); // now there is an image
+ // registered
+ if (image == null) {
+ throw new IllegalStateException("No image could be retrieved for imageId '" + imageId + "'"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return image;
+ }
+
/**
* This method fixes a problem for ImageDescriptors. It returns a corrected
* ImageDescriptor for problematic ImageDescriptors.
@@ -91,22 +133,23 @@
}
- private ImageDescriptor createImageDescriptorForId(String imageId) {
+ private ImageDescriptor createImageDescriptorForId(String providerId, String imageId) {
- if (imageId == null)
+ if (imageId == null || providerId == null)
return null;
+ String registryKey = makeKey(providerId, imageId);
// if image descriptor already exists return it
ImageRegistry imageRegistry = GraphitiUIPlugin.getDefault().getImageRegistry();
- ImageDescriptor imageDescriptor = imageRegistry.getDescriptor(imageId);
+ ImageDescriptor imageDescriptor = imageRegistry.getDescriptor(registryKey);
if (imageDescriptor != null) {
return imageDescriptor;
}
// try get the image-location from the image-providers
- IImageProvider imageProviders[] = ExtensionManager.getSingleton().getImageProviders();
- for (int i = 0; i < imageProviders.length; i++) {
- IImageProvider imageProvider = imageProviders[i];
+ Collection<IImageProvider> imageProviders = ExtensionManager.getSingleton()
+ .getImageProvidersForDiagramTypeProviderId(providerId);
+ for (IImageProvider imageProvider : imageProviders) {
String imageFilePath = imageProvider.getImageFilePath(imageId);
if (imageFilePath != null) {
String pluginId = imageProvider.getPluginId();
@@ -123,8 +166,52 @@
}
imageDescriptor = fixImageDescriptor(imageDescriptor);
- imageRegistry.put(imageId, imageDescriptor);
+ imageRegistry.put(registryKey, imageDescriptor);
return imageDescriptor;
}
+
+ private ImageDescriptor createPlatformImageDescriptorForId(String imageId) {
+
+ if (imageId == null)
+ return null;
+
+ String registryKey = makePlatformKey(imageId);
+ // if image descriptor already exists return it
+ ImageRegistry imageRegistry = GraphitiUIPlugin.getDefault().getImageRegistry();
+ ImageDescriptor imageDescriptor = imageRegistry.getDescriptor(registryKey);
+ if (imageDescriptor != null) {
+ return imageDescriptor;
+ }
+
+ // try get the image-location from the image-providers
+ IImageProvider platformImageProvider = ExtensionManager.getSingleton().getPlatformImageProvider();
+ String imageFilePath = platformImageProvider.getImageFilePath(imageId);
+ if (imageFilePath != null) {
+ String pluginId = platformImageProvider.getPluginId();
+ if (pluginId != null) {
+ // try to create Image from ImageDescriptor (initialize the
+ // ImageRegistry on the fly)
+ imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, imageFilePath);
+ }
+ }
+
+ if (imageDescriptor == null) {
+ imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
+ }
+
+ imageDescriptor = fixImageDescriptor(imageDescriptor);
+ imageRegistry.put(registryKey, imageDescriptor);
+
+ return imageDescriptor;
+ }
+
+ private String makeKey(String dtp, String imageId) {
+ return dtp + "||" + imageId;
+ }
+
+ private String makePlatformKey(String imageId) {
+ return makeKey(PlatformImageProvider.ID, imageId);
+ }
+
}
diff --git a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/services/IImageService.java b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/services/IImageService.java
index e9aa232..83ff5b5 100644
--- a/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/services/IImageService.java
+++ b/plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/services/IImageService.java
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * fvelasco - Bug 396247 - ImageDescriptor changes
*
* </copyright>
*
@@ -25,24 +26,30 @@
* @noextend This class is not intended to be subclassed by clients.
*/
public interface IImageService {
+
/**
* Gets an image descriptor for the given image id. This image id must be
- * supported by an graphiti image provider. The image registry of the plugin
+ * supported by an graphiti image provider, and available to the given
+ * DiagramTypeProvider. The image registry of the plugin
* <code>org.eclipse.graphiti.ui</code> is used. This ensures that the image
* descriptor will only created once.
*
* @param imageId
* the image id which is supported by an graphiti image provider
+ * @param diagramTypeProviderId
+ *
*
* @return the image descriptor for the id
*
* @see org.eclipse.jface.resource.ImageDescriptor
+ * @since 0.10
*/
- ImageDescriptor getImageDescriptorForId(String imageId);
+ ImageDescriptor getImageDescriptorForId(String diagramTypeProviderId, String imageId);
/**
* Gets an image for the given image id. This image id must be supported by
- * an graphiti image provider. The image registry of the plugin
+ * an graphiti image provider, and available to the given
+ * DiagramTypeProvider. The image registry of the plugin
* <code>org.eclipse.graphiti.ui</code> is used. This ensures that the image
* will only created once. The image returned must not be disposed by the
* caller.
@@ -53,8 +60,9 @@
* @return the image for the id
*
* @see org.eclipse.swt.graphics.Image
+ * @since 0.10
*/
- Image getImageForId(String imageId);
+ Image getImageForId(String diagramTypeProviderId, String imageId);
/**
* Removes the corresponding image entry from the image registry and
@@ -71,4 +79,39 @@
* @since 0.9
*/
void removeImageFromRegistry(String imageId);
+
+ /**
+ * Gets an image descriptor for the given image id. This image id must be
+ * supported by the graphiti platform image provider. The image registry of
+ * the plugin <code>org.eclipse.graphiti.ui</code> is used. This ensures
+ * that the image descriptor will only created once.
+ *
+ * @param imageId
+ * the image id which is supported by the graphiti platform image
+ * provider
+ *
+ * @return the image descriptor for the id
+ *
+ * @see org.eclipse.jface.resource.ImageDescriptor
+ * @since 0.10
+ */
+ ImageDescriptor getPlatformImageDescriptorForId(String imageId);
+
+ /**
+ * Gets an image for the given image id. This image id must be supported by
+ * the graphiti platform image provider. The image registry of the plugin
+ * <code>org.eclipse.graphiti.ui</code> is used. This ensures that the image
+ * will only created once. The image returned must not be disposed by the
+ * caller.
+ *
+ * @param imageId
+ * the image id which is supported by the graphiti platform image
+ * provider
+ *
+ * @return the image for the id
+ *
+ * @see org.eclipse.swt.graphics.Image
+ * @since 0.10
+ */
+ Image getPlatformImageForId(String imageId);
}
diff --git a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFPackageTests.java b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFPackageTests.java
index 00e4a08..b895e11 100644
--- a/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFPackageTests.java
+++ b/tests/org.eclipse.graphiti.bot.tests/src/org/eclipse/graphiti/bot/tests/GFPackageTests.java
@@ -12,6 +12,7 @@
* mwenz - Bug 363539 - Enabled feature delegation via IDiagramEditor.execute method
* mgorning - Bug 371671 - addGraphicalRepresentation returns null in dark mode
* mwenz - Felix Velasco - Bug 374918 - Let default paste use LocalSelectionTransfer
+ * fvelasco - Bug 396247 - ImageDescriptor changes
*
* </copyright>
*
@@ -147,7 +148,7 @@
@Test
public void testGraphitiUiInternal() throws Exception {
- org.eclipse.swt.graphics.Image imageForId = GraphitiUi.getImageService().getImageForId(
+ org.eclipse.swt.graphics.Image imageForId = GraphitiUi.getImageService().getPlatformImageForId(
IPlatformImageConstants.IMG_DIAGRAM);
GraphitiUiInternal.getUiService().createImage(imageForId, SWT.IMAGE_GIF);
}