Commit a62c96a2 authored by Simon Barner's avatar Simon Barner

Enable workaround to use text-based checkboxes in tables also on Linux

* Factorize decision to useTextIcon() predicate
* Use unicode labels to display checked/unchecked items

Issue-Ref: 4032
Issue-Url: https://af3-developer.fortiss.org/issues/4032Signed-off-by: Simon Barner's avatarSimon Barner <barner@fortiss.org>
parent 166b735c
AnnotationLabelProvider.java 27d5bbb02d122e603abd158fa5a1fb39e79b0dc5 GREEN
CheckBoxLabelProvider.java 4030bef65a3b919cb087828b4616e5c966380e3e GREEN
CheckBoxLabelProvider.java 894ef9b2ae1a86d8916c8872da1d94b9e3eeb7bf YELLOW
ElementCommentLabelProvider.java 76aa6e9b930ce5680607852fd776172942c89ce5 GREEN
ElementLabelProviderBase.java f33502f73033ebdf30316df627e8a9c87e7d1b28 GREEN
ElementNameLabelProvider.java 897296ac8318b6dfdea9c50fc73aaeea23c2fffa GREEN
......
......@@ -14,7 +14,9 @@
*******************************************************************************/
package org.fortiss.tooling.base.ui.annotation.labelprovider;
import static org.fortiss.tooling.base.utils.SystemUtils.isMacOSXPlatform;
import static org.fortiss.tooling.base.ui.viewers.CheckBoxLabelProvider.CHECKED_LABEL;
import static org.fortiss.tooling.base.ui.viewers.CheckBoxLabelProvider.UNCHECKED_LABEL;
import static org.fortiss.tooling.base.ui.viewers.CheckBoxLabelProvider.useTextIcon;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.EditingSupport;
......@@ -48,10 +50,9 @@ public class CheckBoxLabelProvider extends AnnotationLabelProvider {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
// See #2443
if(isMacOSXPlatform() && element instanceof AnnotationEntry &&
if(useTextIcon() && element instanceof AnnotationEntry &&
((AnnotationEntry)element).canEdit(clazz)) {
return isChecked(element) ? "[X]" : "[ ]";
return isChecked(element) ? CHECKED_LABEL : UNCHECKED_LABEL;
}
return null;
......
AbstractIntegerSpinnerEditingSupport.java 7391e5b0d8e10baf5ab2c7f9543ed732a23bbd9d GREEN
CheckBoxEditingSupport.java 173a63ee86dc396946ddb625a41d48ffad23982f GREEN
CheckBoxLabelProvider.java 4eb2a54a17225da5a0f4f3a4212cde0c23d50d11 GREEN
CheckBoxLabelProvider.java 99285af6cfd2f286123ffbb023d95ae83bf9e0f8 YELLOW
IconNameLabelProvider.java 19eaf843b4b6059c1dc49dca8ede15d07deb30d5 GREEN
......@@ -17,6 +17,7 @@ package org.fortiss.tooling.base.ui.viewers;
import static org.eclipse.core.runtime.Platform.getBundle;
import static org.eclipse.jface.resource.JFaceResources.getImageRegistry;
import static org.fortiss.tooling.base.utils.SystemUtils.isLinuxPlatform;
import static org.fortiss.tooling.base.utils.SystemUtils.isMacOSXPlatform;
import org.eclipse.jface.resource.ImageRegistry;
......@@ -53,6 +54,17 @@ public abstract class CheckBoxLabelProvider extends ColumnLabelProvider {
/** {@link JFaceResources} id for disabled, checked image. */
private static final String DISABLED_CHECKED_KEY = "DISABLED_CHECKED";
/** Predicate whether to use a text-based icon (see #4032 and #2443). */
public static boolean useTextIcon() {
return isMacOSXPlatform() || isLinuxPlatform();
}
/** Text label for unchecked checkboxes when {@link #useTextIcon()} returns {@code true}. */
public static final String UNCHECKED_LABEL = "\u25A1";
/** Text label for checked checkboxes when {@link #useTextIcon()} returns {@code true}. */
public static final String CHECKED_LABEL = "\u2612";
/** Creates an image of checkbox SWT control. */
private static Image makeShot(boolean selected, boolean enabled) {
Shell shell = new Shell(SWT.NO_TRIM);
......@@ -119,8 +131,7 @@ public abstract class CheckBoxLabelProvider extends ColumnLabelProvider {
* @return {@link Image} representing the checkbox.
*/
public static Image getImage(boolean checked, boolean enabled) {
// See #2443
if(isMacOSXPlatform()) {
if(useTextIcon()) {
return null;
}
ImageRegistry imgReg = getImageRegistry();
......@@ -147,9 +158,8 @@ public abstract class CheckBoxLabelProvider extends ColumnLabelProvider {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
// See #2443
if(isMacOSXPlatform() && isEnabled(element)) {
return isChecked(element) ? "[X]" : "[ ]";
if(useTextIcon() && isEnabled(element)) {
return isChecked(element) ? CHECKED_LABEL : UNCHECKED_LABEL;
}
return null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment