diff options
| author | Joseph Carroll | 2012-07-25 14:01:51 +0000 |
|---|---|---|
| committer | Paul Webster | 2012-07-25 14:01:51 +0000 |
| commit | db4addb7450f73bfe58295998ad72491e5ba5b68 (patch) | |
| tree | f45c23e95cdb01de482212eba3e4453fa158435d | |
| parent | 74e3b65cd3a828d76b8d86fa4fcdfeb4b3e0479e (diff) | |
| download | eclipse.platform.ui-db4addb7450f73bfe58295998ad72491e5ba5b68.tar.gz eclipse.platform.ui-db4addb7450f73bfe58295998ad72491e5ba5b68.tar.xz eclipse.platform.ui-db4addb7450f73bfe58295998ad72491e5ba5b68.zip | |
Bug 385414 - Contributing wizards to toolbar always displays icon andv20120725-140151I20120725-1800
text
2 files changed, 24 insertions, 5 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/DirectContributionItem.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/DirectContributionItem.java index ae26f6aea65..ddeb3aa5668 100644 --- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/DirectContributionItem.java +++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/DirectContributionItem.java @@ -1,3 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2010, 2012 IBM Corporation and others. + * 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Joseph Carroll <jdsalingerjr@gmail.com> - Bug 385414 Contributing wizards + * to toolbar always displays icon and text + ******************************************************************************/ package org.eclipse.e4.ui.workbench.renderers.swt; import javax.inject.Inject; @@ -54,6 +66,7 @@ public class DirectContributionItem extends ContributionItem { /** Internal key for transient maps to provide a runnable on widget disposal */ public static final String DISPOSABLE = "IDisposable"; //$NON-NLS-1$ + private static final String FORCE_TEXT = "FORCE_TEXT"; //$NON-NLS-1$ private static final String DCI_STATIC_CONTEXT = "DCI-staticContext"; //$NON-NLS-1$ private MItem model; @@ -126,7 +139,6 @@ public class DirectContributionItem extends ContributionItem { widget.setData(AbstractPartRenderer.OWNING_ME, model); update(null); - updateIcons(); } /* @@ -173,7 +185,6 @@ public class DirectContributionItem extends ContributionItem { widget.setData(AbstractPartRenderer.OWNING_ME, model); update(null); - updateIcons(); } private void updateVisible() { @@ -201,6 +212,7 @@ public class DirectContributionItem extends ContributionItem { */ @Override public void update(String id) { + updateIcons(); if (widget instanceof MenuItem) { updateMenuItem(); } else if (widget instanceof ToolItem) { @@ -223,7 +235,9 @@ public class DirectContributionItem extends ContributionItem { private void updateToolItem() { ToolItem item = (ToolItem) widget; final String text = model.getLocalizedLabel(); - if (text != null) { + Image icon = item.getImage(); + boolean mode = model.getTags().contains(FORCE_TEXT); + if ((icon == null || mode) && text != null) { item.setText(text); } else { item.setText(""); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java index ee7be8529f5..a435a56f0c4 100644 --- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java +++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/HandledContributionItem.java @@ -7,6 +7,8 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Joseph Carroll <jdsalingerjr@gmail.com> - Bug 385414 Contributing wizards + * to toolbar always displays icon and text ******************************************************************************/ package org.eclipse.e4.ui.workbench.renderers.swt; @@ -160,6 +162,7 @@ public class HandledContributionItem extends ContributionItem { // HACK!! local 'static' timerExec...should move out of this class post 4.1 public static ToolItemUpdateTimer toolItemUpdater = new ToolItemUpdateTimer(); + private static final String FORCE_TEXT = "FORCE_TEXT"; //$NON-NLS-1$ private static final String DISPOSABLE_CHECK = "IDisposable"; //$NON-NLS-1$ private static final String WW_SUPPORT = "org.eclipse.ui.IWorkbenchWindow"; //$NON-NLS-1$ private static final String HCI_STATIC_CONTEXT = "HCI-staticContext"; //$NON-NLS-1$ @@ -488,12 +491,12 @@ public class HandledContributionItem extends ContributionItem { */ @Override public void update(String id) { + updateIcons(); if (widget instanceof MenuItem) { updateMenuItem(); } else if (widget instanceof ToolItem) { updateToolItem(); } - updateIcons(); } private void updateMenuItem() { @@ -541,7 +544,9 @@ public class HandledContributionItem extends ContributionItem { private void updateToolItem() { ToolItem item = (ToolItem) widget; final String text = model.getLocalizedLabel(); - if (text != null) { + Image icon = item.getImage(); + boolean mode = model.getTags().contains(FORCE_TEXT); + if ((icon == null || mode) && text != null) { item.setText(text); } else { item.setText(""); //$NON-NLS-1$ |
