aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2014-03-27 07:55:39 (EDT)
committerLars Vogel2014-03-31 16:13:32 (EDT)
commit556c9f7fd8dd53dac8c419cc460c81ac349ade27 (patch)
tree12540c9b0adc67e564ddb294dbe96a8876992f9c
parent023659f7d89519fa9a04da98b1306f66f54c6810 (diff)
downloadeclipse.platform.ui-556c9f7fd8dd53dac8c419cc460c81ac349ade27.zip
eclipse.platform.ui-556c9f7fd8dd53dac8c419cc460c81ac349ade27.tar.gz
eclipse.platform.ui-556c9f7fd8dd53dac8c419cc460c81ac349ade27.tar.bz2
Bug 391961 - MUILabel setIconURI does not work for MPerspectiverefs/changes/26/23826/9
Change-Id: I5599f2a679e00caff5dd705ac48efe028fea0bdc Signed-off-by: Sopot Cela <sopotcela@gmail.com>
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/e4/ui/workbench/addons/perspectiveswitcher/PerspectiveSwitcher.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/e4/ui/workbench/addons/perspectiveswitcher/PerspectiveSwitcher.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/e4/ui/workbench/addons/perspectiveswitcher/PerspectiveSwitcher.java
index 570d155..36745e3 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/e4/ui/workbench/addons/perspectiveswitcher/PerspectiveSwitcher.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/e4/ui/workbench/addons/perspectiveswitcher/PerspectiveSwitcher.java
@@ -7,10 +7,13 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Sopot Cela <sopotcela@gmail.com> - Bug 391961
******************************************************************************/
package org.eclipse.e4.ui.workbench.addons.perspectiveswitcher;
+import java.io.IOException;
+import java.net.URL;
import java.util.Collections;
import java.util.List;
import javax.annotation.PostConstruct;
@@ -26,6 +29,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.e4.core.commands.ECommandService;
import org.eclipse.e4.core.commands.EHandlerService;
import org.eclipse.e4.core.services.events.IEventBroker;
+import org.eclipse.e4.core.services.log.Logger;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.SideValue;
@@ -115,6 +119,9 @@ public class PerspectiveSwitcher {
@Inject
private MWindow window;
+ @Inject
+ private Logger logger;
+
private MToolControl psME;
private ToolBar psTB;
private Composite comp;
@@ -225,6 +232,24 @@ public class PerspectiveSwitcher {
} else if (UIEvents.UILabel.TOOLTIP.equals(attName)) {
String newTTip = (String) newValue;
ti.setToolTipText(newTTip);
+ } else if (UIEvents.UILabel.ICONURI.equals(attName)) {
+ Image currentImage = ti.getImage();
+ String uri = (String) newValue;
+ URL url = null;
+ try {
+ url = new URL(uri);
+ ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
+ if (descriptor == null) {
+ ti.setImage(null);
+ } else
+ ti.setImage(descriptor.createImage());
+ } catch (IOException e) {
+ ti.setImage(null);
+ logger.warn(e);
+ } finally {
+ if (currentImage != null)
+ currentImage.dispose();
+ }
}
}
};
@@ -568,7 +593,9 @@ public class PerspectiveSwitcher {
psItem.addListener(SWT.Dispose, new Listener() {
@Override
public void handleEvent(org.eclipse.swt.widgets.Event event) {
- image.dispose();
+ Image currentImage = psItem.getImage();
+ if (currentImage != null)
+ currentImage.dispose();
}
});
foundImage = true;