Change time display from GMT to local time zone.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / colors / TickColorDialog.java
CommitLineData
ca13a91c
FC
1/*******************************************************************************\r
2 * Copyright (c) 2010 Ericsson\r
3 * \r
4 * All rights reserved. This program and the accompanying materials are\r
5 * made available under the terms of the Eclipse Public License v1.0 which\r
6 * accompanies this distribution, and is available at\r
7 * http://www.eclipse.org/legal/epl-v10.html\r
8 * \r
9 * Contributors:\r
10 * Patrick Tasse - Initial API and implementation\r
11 *******************************************************************************/\r
12\r
13package org.eclipse.linuxtools.tmf.ui.views.colors;\r
14\r
15import java.util.Map;\r
16\r
17import org.eclipse.jface.dialogs.Dialog;\r
d34665f9 18import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
fb5cad3d
PT
19import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphProvider;\r
20import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphProvider;\r
2fa130b8 21import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
fb5cad3d
PT
22import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;\r
23import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphColorScheme;\r
ca13a91c
FC
24import org.eclipse.swt.SWT;\r
25import org.eclipse.swt.events.MouseAdapter;\r
26import org.eclipse.swt.events.MouseEvent;\r
27import org.eclipse.swt.events.PaintEvent;\r
28import org.eclipse.swt.events.PaintListener;\r
29import org.eclipse.swt.graphics.Color;\r
30import org.eclipse.swt.graphics.GC;\r
31import org.eclipse.swt.graphics.Point;\r
32import org.eclipse.swt.graphics.Rectangle;\r
33import org.eclipse.swt.layout.GridData;\r
34import org.eclipse.swt.layout.GridLayout;\r
35import org.eclipse.swt.widgets.Canvas;\r
36import org.eclipse.swt.widgets.Composite;\r
37import org.eclipse.swt.widgets.Control;\r
38import org.eclipse.swt.widgets.Display;\r
39import org.eclipse.swt.widgets.Shell;\r
40\r
41public class TickColorDialog extends Dialog {\r
42\r
43 int selectedIndex = 0;\r
44 Composite colorComposite;\r
45 \r
fb5cad3d
PT
46 TimeGraphColorScheme traceColorScheme = new TimeGraphColorScheme();\r
47 private ITimeGraphProvider timeAnalysisProvider = new TimeGraphProvider() {\r
ca13a91c
FC
48 @Override\r
49 public StateColor getEventColor(ITimeEvent event) {\r
50 return null;\r
51 }\r
52 @Override\r
fb5cad3d 53 public String getTraceClassName(ITimeGraphEntry trace) {\r
ca13a91c
FC
54 return null;\r
55 }\r
56 @Override\r
57 public String getEventName(ITimeEvent event, boolean upper, boolean extInfo) {\r
58 return null;\r
59 }\r
60 @Override\r
61 public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {\r
62 return null;\r
63 }\r
64 @Override\r
65 public String getStateName(StateColor color) {\r
66 return null;\r
67 }};\r
68 \r
69 protected TickColorDialog(Shell shell) {\r
70 super(shell);\r
71 setShellStyle(getShellStyle() | SWT.MAX);\r
72 }\r
73\r
74 /* (non-Javadoc)\r
75 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)\r
76 */\r
77 @Override\r
78 protected Control createDialogArea(Composite parent) {\r
79 getShell().setText(Messages.TickColorDialog_TickColorDialogTitle);\r
80 //getShell().setMinimumSize(getShell().computeSize(500, 200));\r
81 Composite composite = (Composite) super.createDialogArea(parent);\r
82 colorComposite = new Composite(composite, SWT.NONE);\r
83 colorComposite.setLayout(new GridLayout(4, false));\r
84 \r
85 for (int i = 0; i < 16; i++) {\r
86 TickColorCanvas tickColorCanvas = new TickColorCanvas(colorComposite, SWT.NONE);\r
87 tickColorCanvas.setColorIndex(i);\r
88 }\r
89\r
90 return composite;\r
91 }\r
92\r
93 public void setColorIndex(int colorIndex) {\r
94 selectedIndex = colorIndex;\r
95 }\r
96 \r
97 public int getColorIndex() {\r
98 return selectedIndex;\r
99 }\r
100 \r
101 private class TickColorCanvas extends Canvas {\r
102 int colorIndex;\r
103 \r
104 public TickColorCanvas(Composite parent, int style) {\r
105 super(parent, style);\r
106 \r
107 GridData gd = new GridData(SWT.CENTER, SWT.FILL, true, false);\r
108 gd.widthHint = 40;\r
109 gd.heightHint = 25;\r
110 setLayoutData(gd);\r
111 setBackground(traceColorScheme.getBkColor(false, false, false));\r
112 \r
113 addPaintListener(new PaintListener() {\r
114 @Override\r
115 public void paintControl(PaintEvent e) {\r
fb5cad3d 116 e.gc.setForeground(traceColorScheme.getColor(TimeGraphColorScheme.MID_LINE));\r
ca13a91c
FC
117 int midy = e.y + e.height / 2;\r
118 e.gc.drawLine(e.x, midy, e.x + e.width, midy);\r
119 int midx = e.x + e.width / 2;\r
120 Rectangle rect = new Rectangle(midx - 10, e.y + 3, 0, e.height - 6);\r
121 for (int i = 1; i <= 3; i++) {\r
122 rect.x += i;\r
123 rect.width = i;\r
124 timeAnalysisProvider.drawState(traceColorScheme, colorIndex, rect, e.gc, false, false, false);\r
125 }\r
126 for (int i = 3; i > 0; i--) {\r
127 rect.x += i + 2;\r
128 rect.width = i;\r
129 timeAnalysisProvider.drawState(traceColorScheme, colorIndex, rect, e.gc, false, false, false);\r
130 }\r
131 if (selectedIndex == colorIndex) {\r
132 Color borderColor = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);\r
133 Point p = TickColorCanvas.this.getSize();\r
134 rect = new Rectangle(0, 0, p.x - 1, p.y - 1);\r
135 GC gc = e.gc;\r
136 gc.setForeground(borderColor);\r
137 gc.drawRectangle(rect);\r
138 }\r
139 }});\r
140 \r
141 addMouseListener(new MouseAdapter() {\r
142 @Override\r
143 public void mouseUp(MouseEvent e) {\r
144 selectedIndex = colorIndex;\r
145 colorComposite.redraw(0, 0, colorComposite.getBounds().width, colorComposite.getBounds().height, true);\r
146 }});\r
147 }\r
148\r
149 public void setColorIndex(int index) {\r
150 colorIndex = index;\r
151 }\r
152 }\r
153 \r
154 \r
155}\r
This page took 0.034424 seconds and 5 git commands to generate.