OpenCores
URL https://opencores.org/ocsvn/adv_debug_sys/adv_debug_sys/trunk

Subversion Repositories adv_debug_sys

[/] [adv_debug_sys/] [trunk/] [Software/] [AdvancedWatchpointControl/] [src/] [advancedWatchpointControl/] [guiControlGroup.java] - Blame information for rev 54

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 54 nyawn
////////////////////////////////////////////////////////////////
2
//
3
// guiControlGroup.java
4
//
5
// Copyright (C) 2010 Nathan Yawn 
6
//                    (nyawn@opencores.org)
7
//
8
// This class holds the GUI elements for the control group,
9
// which includes the read and write button, along with the
10
// message output window.
11
//
12
////////////////////////////////////////////////////////////////
13
//
14
// This source file may be used and distributed without
15
// restriction provided that this copyright statement is not
16
// removed from the file and that any derivative work contains
17
// the original copyright notice and the associated disclaimer.
18
// 
19
// This source file is free software; you can redistribute it
20
// and/or modify it under the terms of the GNU General
21
// Public License as published by the Free Software Foundation;
22
// either version 3.0 of the License, or (at your option) any
23
// later version.
24
//
25
// This source is distributed in the hope that it will be
26
// useful, but WITHOUT ANY WARRANTY; without even the implied 
27
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
28
// PURPOSE.  See the GNU Lesser General Public License for more
29
// details.
30
// 
31
// You should have received a copy of the GNU General
32
// Public License along with this source; if not, download it 
33
// from http://www.gnu.org/licenses/gpl.html
34
//
35
////////////////////////////////////////////////////////////////
36 51 nyawn
package advancedWatchpointControl;
37 54 nyawn
 
38 51 nyawn
import java.text.SimpleDateFormat;
39
import org.eclipse.swt.SWT;
40
import org.eclipse.swt.graphics.FontMetrics;
41
import org.eclipse.swt.graphics.GC;
42
import org.eclipse.swt.layout.GridData;
43
import org.eclipse.swt.layout.GridLayout;
44
import org.eclipse.swt.widgets.Button;
45
import org.eclipse.swt.widgets.Composite;
46
import org.eclipse.swt.widgets.Group;
47
import org.eclipse.swt.widgets.Text;
48
 
49
public class guiControlGroup implements LogMessageObserver {
50
 
51
        private Group miscGroup = null;
52
        private Button applyButton = null;
53
        private Button rereadButton = null;
54
        private Group messagesGroup = null;
55
        private Text notifyMessageLabel = null;
56
        private mainControl mCtrl = null;
57
 
58
        public guiControlGroup(Composite parent, mainControl mc) {
59
                mCtrl = mc;
60
                GridLayout gridLayout2 = new GridLayout();
61
                gridLayout2.numColumns = 2;
62
                gridLayout2.horizontalSpacing = 10;
63
                gridLayout2.makeColumnsEqualWidth = false;
64
                miscGroup = new Group(parent, SWT.NONE);
65
                miscGroup.setText("Control");
66
                applyButton = new Button(miscGroup, SWT.NONE);
67
                applyButton.setText("Write Registers");
68
                applyButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
69
                        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
70
                                mCtrl.doWriteAllRegisters();
71
                        }
72
                });
73
                createMessagesGroup();
74
                rereadButton = new Button(miscGroup, SWT.NONE);
75
                rereadButton.setText("Read Registers");
76
                rereadButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
77
                                        public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
78
                                                mCtrl.doReadAllRegisters();
79
                                        }
80
                                });
81
                miscGroup.setLayout(gridLayout2);
82
                mCtrl.registerForLogMessages(this);
83
        }
84
 
85
 
86
        private void createMessagesGroup() {
87
                GridData gridData6 = new GridData();
88
                gridData6.verticalSpan = 2;
89
                gridData6.grabExcessHorizontalSpace = true;
90
                gridData6.horizontalAlignment = GridData.FILL;
91
                gridData6.verticalAlignment = GridData.FILL;
92
                gridData6.grabExcessVerticalSpace = true;
93
                messagesGroup = new Group(miscGroup, SWT.NONE);
94
                messagesGroup.setLayout(new GridLayout());
95
                messagesGroup.setLayoutData(gridData6);
96
                messagesGroup.setText("Messages");
97
 
98
                notifyMessageLabel = new Text(messagesGroup, SWT.MULTI|SWT.READ_ONLY);
99
            java.util.Date today = new java.util.Date();
100
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS  ");
101
                notifyMessageLabel.setText(sdf.format(today) + "Ready");
102
 
103
                int columns = 100;
104
                int rows = 4;
105
            GC gc = new GC (notifyMessageLabel);
106
            FontMetrics fm = gc.getFontMetrics ();
107
            int width = columns * fm.getAverageCharWidth ();
108
            int height = rows * fm.getHeight ();
109
            gc.dispose ();
110
 
111
            gridData6 = new GridData();
112
            gridData6.widthHint = width;
113
            gridData6.heightHint = height;
114
                notifyMessageLabel.setLayoutData(gridData6);
115
        }
116
 
117
        public void notifyLogMessage() {
118
                String msg = mCtrl.getLogMessage();
119
            java.util.Date today = new java.util.Date();
120
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS  ");
121
                notifyMessageLabel.append("\n" + sdf.format(today) + msg);
122
                System.out.print(sdf.format(today) + msg + "\n");
123
        }
124
 
125
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.