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/] [guiServerGroup.java] - Blame information for rev 62

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 54 nyawn
////////////////////////////////////////////////////////////////
2
//
3
// guiServerGroup.java
4
//
5
// Copyright (C) 2010 Nathan Yawn 
6
//                    (nyawn@opencores.org)
7
//
8
// This class contains the GUI elements related to the server
9
// connection.  This includes the server address and port
10
// number, the connect button, and the network status message
11
// display.
12
//
13
////////////////////////////////////////////////////////////////
14
//
15
// This source file may be used and distributed without
16
// restriction provided that this copyright statement is not
17
// removed from the file and that any derivative work contains
18
// the original copyright notice and the associated disclaimer.
19
// 
20
// This source file is free software; you can redistribute it
21
// and/or modify it under the terms of the GNU General
22
// Public License as published by the Free Software Foundation;
23
// either version 3.0 of the License, or (at your option) any
24
// later version.
25
//
26
// This source is distributed in the hope that it will be
27
// useful, but WITHOUT ANY WARRANTY; without even the implied 
28
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
29
// PURPOSE.  See the GNU Lesser General Public License for more
30
// details.
31
// 
32
// You should have received a copy of the GNU General
33
// Public License along with this source; if not, download it 
34
// from http://www.gnu.org/licenses/gpl.html
35
//
36
////////////////////////////////////////////////////////////////
37 51 nyawn
package advancedWatchpointControl;
38 54 nyawn
 
39 51 nyawn
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.Label;
48
import org.eclipse.swt.widgets.Text;
49
 
50
 
51
public class guiServerGroup implements NetworkStatusObserver {
52
 
53
        private Group serverGroup = null;
54
        private GridLayout serverGroupLayout = null;
55
        private Button serverConnectButton = null;
56
        private Group serverHostnameGroup = null;
57
        private Text serverHostnameText = null;
58
        private Group tcpPortGroup = null;
59
        private Text tcpPortText = null;
60
        private Group networkStatusGroup = null;
61
        private Label connectionStatusLabel = null;
62
        private mainControl mCtrl = null;
63
 
64
        public guiServerGroup(Composite parent, mainControl mc) {
65
                        mCtrl = mc;
66
                        serverGroup = new Group(parent, SWT.NONE);
67
                        serverGroupLayout = new GridLayout();
68
 
69
                        serverGroupLayout.numColumns = 4;
70
 
71
                        serverGroup.setLayout(serverGroupLayout);
72
                        serverGroup.setText("Server Connection");
73
 
74
                        createServerHostnameGroup();
75
                        createTcpPortGroup();
76
                        serverConnectButton = new Button(serverGroup, SWT.NONE);
77
                        serverConnectButton.setText("Connect");
78
                        serverConnectButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
79
                                public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
80
                                        int port = Integer.parseInt(tcpPortText.getText());
81
                                        if(mCtrl != null) {
82
                                                mCtrl.doNetworkConnect(serverHostnameText.getText(), port);
83
                                        }
84
                                }
85
                        });
86
                        createNetworkStatusGroup();
87
 
88
                        mCtrl.registerForNetworkStatusUpdates(this);
89
        }
90
 
91
        private void createServerHostnameGroup() {
92
                serverHostnameGroup = new Group(serverGroup, SWT.NONE);
93
                serverHostnameGroup.setLayout(new GridLayout());
94
                serverHostnameGroup.setText("Server Hostname");
95
                serverHostnameText = new Text(serverHostnameGroup, SWT.BORDER);
96
                serverHostnameText.setText("localhost");
97
 
98
                // Make the Text box a bit bigger than default
99
                int columns = 20;
100
            GC gc = new GC (serverHostnameText);
101
            FontMetrics fm = gc.getFontMetrics ();
102
            int width = columns * fm.getAverageCharWidth ();
103
            int height = fm.getHeight ();
104
            gc.dispose ();
105
            // This doesn't seem to work, need to use gd.widthHint/heightHint below
106
 
107
                GridData gd = new GridData();
108
                gd.grabExcessHorizontalSpace = true;
109
                gd.verticalAlignment = GridData.CENTER;
110
                gd.horizontalAlignment = GridData.FILL;
111
                gd.widthHint = width;
112
                gd.heightHint = height;
113
                serverHostnameText.setLayoutData(gd);
114
        }
115
 
116
        private void createTcpPortGroup() {
117
                tcpPortGroup = new Group(serverGroup, SWT.NONE);
118
                tcpPortGroup.setLayout(new GridLayout());
119
                tcpPortGroup.setText("Server Port");
120
                tcpPortText = new Text(tcpPortGroup, SWT.BORDER);
121
                tcpPortText.setText("9928");
122
                GridData gd = new GridData();
123
                gd.horizontalAlignment = GridData.FILL;
124
                gd.grabExcessHorizontalSpace = true;
125
                gd.verticalAlignment = GridData.CENTER;
126
                tcpPortText.setLayoutData(gd);
127
        }
128
 
129
        private void createNetworkStatusGroup() {
130
                networkStatusGroup = new Group(serverGroup, SWT.NONE);
131
                networkStatusGroup.setText("Connection Status");
132
                GridLayout gl = new GridLayout();
133
                gl.makeColumnsEqualWidth = false;
134
                networkStatusGroup.setLayout(gl);
135
 
136
                GridData gd = new GridData();
137
                gd.horizontalAlignment = GridData.FILL;
138
                gd.grabExcessHorizontalSpace = true;
139
                networkStatusGroup.setLayoutData(gd);
140
 
141
                connectionStatusLabel = new Label(networkStatusGroup, SWT.NONE);
142
                connectionStatusLabel.setText("Not Connected");  // cheating - doesn't through mainControl
143
                gd = new GridData();
144
                gd.grabExcessHorizontalSpace = true;
145
                gd.verticalAlignment = GridData.CENTER;
146
                gd.horizontalAlignment = GridData.FILL;
147
                connectionStatusLabel.setLayoutData(gd);
148
        }
149
 
150
        public void notifyNetworkStatus() {
151
                // *** Limit length?
152
                connectionStatusLabel.setText(mCtrl.getNetworkStatus());
153
        }
154
}

powered by: WebSVN 2.1.0

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