From f97d518394ee6f939b6f7151e7b0d8d90fef5b16 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Thu, 5 Apr 2018 11:39:02 +0200 Subject: Bug 533252 - Iterate over entrySet in org.eclipse.swt.examples.controlexample.ColorTab Change-Id: Iffd49a876ba34081eaf69c1f906c90fae363a4e8 Signed-off-by: Lars Vogel --- .../swt/examples/controlexample/ColorTab.java | 44 +++++++++++----------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ColorTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ColorTab.java index f8003c050a..48151becb7 100644 --- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ColorTab.java +++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ColorTab.java @@ -15,6 +15,7 @@ package org.eclipse.swt.examples.controlexample; import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; import java.util.HashMap; +import java.util.Map.Entry; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionListener; @@ -112,31 +113,32 @@ class ColorTab extends Tab { } // fill in the Data. Put an empty line inbetween "Named" and "SWT" colors. boolean emptyLineFlag=false; - for (Integer key : hmap.keySet()){ - if (!emptyLineFlag){ - TableItem item = new TableItem (colors, SWT.NONE); - item.setText(hmap.get(key)); - item.setText(0,hmap.get(key)); - item.setText(1,"Named"); - item.setText(2,getRGBcolor(key)); - // the spaces will help the color cell be large enough to see - item.setText(3," "); - item.setBackground(3,display.getSystemColor(key)); - if(key == namedColorEnd){ + for (Entry entry : hmap.entrySet()) { + Integer key = entry.getKey(); + String value = entry.getValue(); + if (!emptyLineFlag) { + TableItem item = new TableItem(colors, SWT.NONE); + item.setText(value); + item.setText(0, value); + item.setText(1, "Named"); + item.setText(2, getRGBcolor(key)); + // the spaces will help the color cell be large enough to see + item.setText(3, " "); + item.setBackground(3, display.getSystemColor(key)); + if (key == namedColorEnd) { TableItem emptyItem = new TableItem(colors, SWT.NONE); emptyItem.setText(""); - emptyLineFlag=true; + emptyLineFlag = true; } - } - else{ - TableItem item = new TableItem (colors, SWT.NONE); - item.setText(hmap.get(key)); - item.setText(0,hmap.get(key)+" "); - item.setText(1,"System "); - item.setText(2,getRGBcolor(key)+" "); + } else { + TableItem item = new TableItem(colors, SWT.NONE); + item.setText(value); + item.setText(0, value + " "); + item.setText(1, "System "); + item.setText(2, getRGBcolor(key) + " "); // the spaces will help the color cell be large enough to see - item.setText(3," "); - item.setBackground(3,display.getSystemColor(key)); + item.setText(3, " "); + item.setBackground(3, display.getSystemColor(key)); } } for (int i = 0; i < columnTitles.length; i++) { -- cgit v1.2.3