diff options
author | Lars Vogel | 2018-04-05 09:39:02 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2018-04-13 05:22:10 +0000 |
commit | f97d518394ee6f939b6f7151e7b0d8d90fef5b16 (patch) | |
tree | d8c6f949579e118e95c54c69dd2653ed5b80adbb | |
parent | 38a2849b03413b2e2aec483a66205f7723ac9df9 (diff) | |
download | eclipse.platform.swt-f97d518394ee6f939b6f7151e7b0d8d90fef5b16.tar.gz eclipse.platform.swt-f97d518394ee6f939b6f7151e7b0d8d90fef5b16.tar.xz eclipse.platform.swt-f97d518394ee6f939b6f7151e7b0d8d90fef5b16.zip |
Bug 533252 - Iterate over entrySet in
org.eclipse.swt.examples.controlexample.ColorTab
Change-Id: Iffd49a876ba34081eaf69c1f906c90fae363a4e8
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r-- | examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ColorTab.java | 44 |
1 files 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<Integer, String> 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++) { |