|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.carbide.cpp.pi.util; |
|
19 |
|
20 import java.util.ArrayList; |
|
21 import java.util.HashMap; |
|
22 import java.util.Iterator; |
|
23 import java.util.Map; |
|
24 |
|
25 import org.eclipse.swt.SWT; |
|
26 import org.eclipse.swt.custom.CLabel; |
|
27 import org.eclipse.swt.events.SelectionAdapter; |
|
28 import org.eclipse.swt.events.SelectionEvent; |
|
29 import org.eclipse.swt.graphics.Color; |
|
30 import org.eclipse.swt.graphics.Point; |
|
31 import org.eclipse.swt.graphics.RGB; |
|
32 import org.eclipse.swt.layout.RowLayout; |
|
33 import org.eclipse.swt.widgets.Button; |
|
34 import org.eclipse.swt.widgets.Display; |
|
35 import org.eclipse.swt.widgets.Shell; |
|
36 |
|
37 /* |
|
38 * |
|
39 * This class just make a list of numbers and assign color to them |
|
40 * Testers should |
|
41 * 1.visually verify color if it looks good to them |
|
42 * 2.try to assign different color to different entries |
|
43 * 3.try to assign the same color to different entries and observe error message |
|
44 * |
|
45 * */ |
|
46 |
|
47 public class TestDataMiningPalette { |
|
48 |
|
49 private Shell sShell = null; |
|
50 |
|
51 private Map<Button,CLabel> dataMiningColors = new HashMap<Button,CLabel>(); |
|
52 private DataMiningPalette palette = new DataMiningPalette(); |
|
53 private ArrayList<Integer> sosThreadlist = new ArrayList<Integer>(); |
|
54 private ArrayList<Integer> threadlist = new ArrayList<Integer>(); |
|
55 |
|
56 |
|
57 /** |
|
58 * @param args |
|
59 */ |
|
60 public static void main(String[] args) { |
|
61 Display display = Display.getDefault(); |
|
62 TestDataMiningPalette thisClass = new TestDataMiningPalette(); |
|
63 thisClass.createSShell(); |
|
64 thisClass.sShell.open(); |
|
65 |
|
66 while (!thisClass.sShell.isDisposed()) { |
|
67 if (!display.readAndDispatch()) |
|
68 display.sleep(); |
|
69 } |
|
70 display.dispose(); |
|
71 } |
|
72 |
|
73 /** |
|
74 * This method initializes sShell |
|
75 */ |
|
76 private void createSShell() { |
|
77 sShell = new Shell(); |
|
78 sShell.setText(Messages.getString("TestDataMiningPalette.shell")); //$NON-NLS-1$ |
|
79 sShell.setSize(new Point(1000, 700)); |
|
80 |
|
81 RowLayout layout = new RowLayout(); |
|
82 sShell.setLayout(layout); |
|
83 |
|
84 for (int i = 0; i < 216; i++) { |
|
85 sosThreadlist.add(i); |
|
86 } |
|
87 for (int i = 216; i < 216 + 255; i++) { |
|
88 threadlist.add(i); |
|
89 } |
|
90 palette.assignSOSColor(sosThreadlist); |
|
91 palette.assignColor(threadlist); |
|
92 |
|
93 sosThreadlist.addAll(threadlist); |
|
94 |
|
95 Iterator entryItr = sosThreadlist.iterator(); |
|
96 |
|
97 while(entryItr.hasNext()) |
|
98 { |
|
99 Object entry = entryItr.next(); |
|
100 |
|
101 final Button button = new Button(sShell, SWT.NONE); |
|
102 button.setText(entry.toString()); |
|
103 button.setBackground(new Color(Display.getCurrent(), palette.getRGB(entry))); |
|
104 button.addSelectionListener(new SelectionAdapter() { |
|
105 public void widgetSelected(SelectionEvent e) { |
|
106 Integer index = new Integer(button.getText()); |
|
107 if(palette.recolorEntryDialog(sShell, index)) |
|
108 { |
|
109 RGB newRGB = palette.getRGB(index); |
|
110 CLabel myLabel = dataMiningColors.get(button); |
|
111 myLabel.setBackground(new Color(Display.getCurrent(), newRGB)); |
|
112 } |
|
113 } |
|
114 }); |
|
115 CLabel cLabel = new CLabel(sShell, SWT.NONE); |
|
116 cLabel.setText(entry.toString()); |
|
117 cLabel.setBackground(new Color(Display.getCurrent(), palette.getRGB(entry))); |
|
118 dataMiningColors.put(button, cLabel); |
|
119 } |
|
120 } |
|
121 |
|
122 } |