Package: SelectTimeDialog$1

SelectTimeDialog$1

nameinstructionbranchcomplexitylinemethod
widgetSelected(SelectionEvent)
M: 27 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
{...}
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * RT Trace Viewer Plugin
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.plugins.rttraceviewer.view;
23:
24:
25: import java.util.List;
26:
27: import org.eclipse.jface.dialogs.TitleAreaDialog;
28: import org.eclipse.swt.events.SelectionAdapter;
29: import org.eclipse.swt.events.SelectionEvent;
30: import org.eclipse.swt.layout.GridData;
31: import org.eclipse.swt.layout.GridLayout;
32: import org.eclipse.swt.widgets.Combo;
33: import org.eclipse.swt.widgets.Composite;
34: import org.eclipse.swt.widgets.Control;
35: import org.eclipse.swt.widgets.Label;
36: import org.eclipse.swt.widgets.Shell;
37:
38:
39: public class SelectTimeDialog extends TitleAreaDialog
40: {
41:
42:
43:         public SelectTimeDialog(Shell parentShell, List<Long> pTimes)
44: {
45: super(parentShell);
46: currentTime = 0L;
47: theTimes = null;
48: theCombo = null;
49: selectedTime = 0L;
50: theTimes = pTimes;
51: }
52:
53: public SelectTimeDialog(Shell parentShell, List<Long> pTimes, long pcurTime)
54: {
55: super(parentShell);
56: currentTime = 0L;
57: theTimes = null;
58: theCombo = null;
59: selectedTime = 0L;
60: theTimes = pTimes;
61: currentTime = pcurTime;
62: }
63:
64: @Override
65:         public void create()
66: {
67: super.create();
68: setTitle("Select time");
69: setMessage("Select the appropriate starting time for the execution overview");
70: }
71:
72: @Override
73:         protected Control createDialogArea(Composite parent)
74: {
75: Composite area = new Composite(parent, 0);
76: GridLayout layout = new GridLayout();
77: layout.numColumns = 2;
78: layout.marginWidth = 15;
79: layout.marginHeight = 20;
80: layout.horizontalSpacing = 15;
81: area.setLayout(layout);
82: Label theLabel = new Label(area, 16384);
83: theLabel.setText("Draw diagram from");
84: theCombo = new Combo(area, 2060);
85: GridData gd = new GridData();
86: gd.widthHint = 200;
87: theCombo.setLayoutData(gd);
88: theCombo.addSelectionListener(new SelectionAdapter() {
89:
90: @Override
91:                         public void widgetSelected(SelectionEvent e)
92: {
93: int idx = theCombo.getSelectionIndex();
94:• if(idx >= 0)
95: {
96: Long theValue = (Long)theTimes.get(idx);
97: selectedTime = theValue.longValue();
98: } else
99: {
100: selectedTime = currentTime;
101: }
102: }
103:
104: });
105: int cnt = 0;
106: int idx = 0;
107:
108: for(Long t : theTimes)
109: {
110:         theCombo.add(t.toString());
111:         
112: if(t.longValue() == currentTime)
113: {
114: idx = cnt;
115: }
116:
117: cnt++;
118: }
119:
120: theCombo.select(idx);
121: return area;
122: }
123:
124: private long currentTime;
125: private List<Long> theTimes;
126: private Combo theCombo;
127: public long selectedTime;
128:
129:
130:
131: }