Source Code Cross Referenced for DialogIPOptions.java in  » Net » GNetWatch » net » fenyo » gnetwatch » GUI » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » GNetWatch » net.fenyo.gnetwatch.GUI 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * GNetWatch
003:         * Copyright 2006, 2007 Alexandre Fenyo
004:         * gnetwatch@fenyo.net
005:         *
006:         * This file is part of GNetWatch.
007:         *
008:         * GNetWatch is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU General Public License as published by
010:         * the Free Software Foundation; either version 2 of the License, or
011:         * (at your option) any later version.
012:         *
013:         * GNetWatch is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with GNetWatch; if not, write to the Free Software
020:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
021:         */
022:
023:        package net.fenyo.gnetwatch.GUI;
024:
025:        import java.net.UnknownHostException;
026:
027:        import net.fenyo.gnetwatch.AlgorithmException;
028:        import net.fenyo.gnetwatch.GenericTools;
029:        import net.fenyo.gnetwatch.targets.TargetIPv4Subnet;
030:
031:        import org.apache.commons.logging.Log;
032:        import org.apache.commons.logging.LogFactory;
033:
034:        import org.eclipse.swt.*;
035:        import org.eclipse.swt.widgets.*;
036:        import org.eclipse.swt.layout.*;
037:        import org.eclipse.swt.custom.*;
038:        import org.eclipse.swt.events.*;
039:        import org.eclipse.swt.graphics.*;
040:        import org.eclipse.swt.browser.*;
041:
042:        /**
043:         * This class manages the "IP options" dialog.
044:         * @author Alexandre Fenyo
045:         * @version $Id: DialogIPOptions.java,v 1.13 2007/03/07 22:08:27 fenyo Exp $
046:         */
047:
048:        /*
049:         * port src
050:         * port dst
051:         * DSCP
052:         * taille des paquets (cf. setSendBufferSize()) pdu max size
053:         *
054:         * proxy yes/no
055:         * proxy host
056:         * proxy port
057:         * URL
058:         * reconnect after each GET yes/no
059:         * number of parallel sessions
060:         */
061:
062:        public class DialogIPOptions extends Dialog {
063:            private static Log log = LogFactory.getLog(DialogIPOptions.class);
064:
065:            private final GUI gui;
066:
067:            private final int bglevel = 100;
068:
069:            private String[] dscp = new String[] { "000000 - CS0 - default",
070:                    "000001", "000010", "000011", "000100", "000101", "000110",
071:                    "000111", "001000 - CS1", "001001", "001010 - AF11",
072:                    "001011", "001100 - AF12", "001101", "001110 - AF13",
073:                    "001111", "010000 - CS2", "010001", "010010 - AF21",
074:                    "010011", "010100 - AF22", "010101", "010110 - AF23",
075:                    "010111", "011000 - CS3", "011001", "011010 - AF31",
076:                    "011011", "011100 - AF32", "011101", "011110 - AF33",
077:                    "011111", "100000 - CS4", "100001", "100010  - AF41",
078:                    "100011", "100100  - AF42", "100101", "100110  - AF43",
079:                    "100111", "101000 - CS5", "101001", "101010", "101011",
080:                    "101100", "101101", "101110 - EF", "101111",
081:                    "110000 - CS6", "110001", "110010", "110011", "110100",
082:                    "110101", "110110", "110111", "111000 - CS7", "111001",
083:                    "111010", "111011", "111100", "111101", "111110", "111111", };
084:
085:            private GridLayout layout = null;
086:            private Composite groups_composite = null;
087:            private Composite bottom_composite = null;
088:            private RowLayout groups_composite_layout = null;
089:            private RowLayout bottom_composite_layout = null;
090:            private GridData groups_composite_grid_data = null;
091:            private Group group_network_parameters = null;
092:            private GridLayout group_network_parameters_layout = null;
093:
094:            private int tos = 0;
095:            private int port_src = 10000;
096:            private int port_dst = 10000;
097:            private int pdu_max_size = 1400;
098:
099:            /**
100:             * Constructor.
101:             * @param gui current GUI instance.
102:             * @param parent parent shell.
103:             */
104:            public DialogIPOptions(final GUI gui, final Shell parent) {
105:                super (parent, 0);
106:                this .gui = gui;
107:            }
108:
109:            /**
110:             * Gets the IP type of service.
111:             * @param none.
112:             * @return int type of service.
113:             */
114:            public int getTOS() {
115:                return tos;
116:            }
117:
118:            /**
119:             * Gets the source port.
120:             * @param none.
121:             * @return int source port.
122:             */
123:            public int getPortSrc() {
124:                return port_src;
125:            }
126:
127:            /**
128:             * Gets the destination port.
129:             * @return int destination port.
130:             */
131:            public int getPortDst() {
132:                return port_dst;
133:            }
134:
135:            /**
136:             * Gets the PDU maximum size.
137:             * @param none.
138:             * @return int PDU maximum size.
139:             */
140:            public int getPDUMaxSize() {
141:                return pdu_max_size;
142:            }
143:
144:            /**
145:             * Sets the type of service.
146:             * @param tos type of service.
147:             * @return void.
148:             */
149:            public void setTOS(final int tos) {
150:                this .tos = tos;
151:            }
152:
153:            /**
154:             * Sets the source port.
155:             * @param port_src source port.
156:             * @return void.
157:             */
158:            public void setPortSrc(final int port_src) {
159:                this .port_src = port_src;
160:            }
161:
162:            /**
163:             * Sets the destination port.
164:             * @param port_dst destination port.
165:             * @return void.
166:             */
167:            public void setPortDst(final int port_dst) {
168:                this .port_dst = port_dst;
169:            }
170:
171:            /**
172:             * Sets the PDU maximum size.
173:             * @param pdu_max_size PDU maximum size.
174:             * @return void.
175:             */
176:            public void setPDUMaxSize(final int pdu_max_size) {
177:                this .pdu_max_size = pdu_max_size;
178:            }
179:
180:            /**
181:             * Displays the dialog.
182:             * @param none.
183:             * @return void.
184:             */
185:            public void open() {
186:                final Shell parent = getParent();
187:                final Display display = parent.getDisplay();
188:                final Shell shell = new Shell(parent, SWT.DIALOG_TRIM
189:                        | SWT.APPLICATION_MODAL);
190:                shell
191:                        .setText(gui.getConfig().getString(
192:                                "gnetwatch_ip_options"));
193:                //    shell.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_BLUE));
194:
195:                // Your code goes here (widget creation, set result, etc).
196:                // Composite for groups at left
197:                layout = new GridLayout();
198:                layout.numColumns = 1;
199:                layout.marginHeight = 2;
200:                layout.marginWidth = 2;
201:                layout.verticalSpacing = 1;
202:                shell.setLayout(layout);
203:
204:                groups_composite = new Composite(shell, SWT.FLAT);
205:                groups_composite_layout = new RowLayout(SWT.VERTICAL);
206:                groups_composite_layout.fill = true;
207:                groups_composite_layout.marginTop = 0;
208:                groups_composite_layout.marginBottom = 0;
209:                groups_composite.setLayout(groups_composite_layout);
210:                groups_composite_grid_data = new GridData(
211:                        GridData.FILL_VERTICAL);
212:                groups_composite.setLayoutData(groups_composite_grid_data);
213:
214:                // Group for network parameters
215:
216:                group_network_parameters = new Group(groups_composite,
217:                        SWT.SHADOW_ETCHED_IN);
218:                group_network_parameters_layout = new GridLayout();
219:                group_network_parameters_layout.numColumns = 2;
220:                group_network_parameters
221:                        .setLayout(group_network_parameters_layout);
222:                group_network_parameters.setText(gui.getConfig().getString(
223:                        "network_parameters"));
224:
225:                // RFC 3260
226:                final Label label_tos = new Label(group_network_parameters,
227:                        SWT.SHADOW_IN);
228:                label_tos.setText(gui.getConfig().getString("dscp_name"));
229:                label_tos.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
230:                final Combo ctos = new Combo(group_network_parameters,
231:                        SWT.SHADOW_IN | SWT.READ_ONLY);
232:                ctos.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
233:                for (final String tos : dscp)
234:                    ctos.add(tos);
235:                ctos.setText(dscp[tos]);
236:
237:                final Label label_packet_size = new Label(
238:                        group_network_parameters, SWT.SHADOW_IN);
239:                label_packet_size.setText(gui.getConfig().getString(
240:                        "pdu_max_size"));
241:                label_packet_size.setLayoutData(new GridData(
242:                        GridData.FILL_HORIZONTAL));
243:                final Spinner packet_size = new Spinner(
244:                        group_network_parameters, SWT.WRAP);
245:                packet_size
246:                        .setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
247:                packet_size.setMinimum(0);
248:                packet_size.setMaximum(10000);
249:                packet_size.setSelection(this .pdu_max_size);
250:
251:                final Label label_port_src = new Label(
252:                        group_network_parameters, SWT.SHADOW_IN);
253:                label_port_src
254:                        .setText(gui.getConfig().getString("source_port"));
255:                label_port_src.setLayoutData(new GridData(
256:                        GridData.FILL_HORIZONTAL));
257:                final Spinner port_src = new Spinner(group_network_parameters,
258:                        SWT.WRAP);
259:                port_src.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
260:                port_src.setMinimum(1);
261:                port_src.setMaximum(65535);
262:                port_src.setSelection(this .port_src);
263:
264:                final Label label_port_dst = new Label(
265:                        group_network_parameters, SWT.SHADOW_IN);
266:                label_port_dst.setText(gui.getConfig().getString(
267:                        "destination_port"));
268:                label_port_dst.setLayoutData(new GridData(
269:                        GridData.FILL_HORIZONTAL));
270:                final Spinner port_dst = new Spinner(group_network_parameters,
271:                        SWT.WRAP);
272:                port_dst.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
273:                port_dst.setMinimum(0);
274:                port_dst.setMaximum(65535);
275:                port_dst.setSelection(this .port_dst);
276:
277:                // bottom buttons
278:
279:                bottom_composite = new Composite(shell, SWT.FLAT);
280:                bottom_composite_layout = new RowLayout();
281:                bottom_composite_layout.fill = true;
282:                bottom_composite_layout.marginTop = 0;
283:                bottom_composite_layout.marginBottom = 0;
284:                bottom_composite_layout.wrap = false;
285:                bottom_composite_layout.pack = false;
286:                bottom_composite_layout.justify = true;
287:                bottom_composite_layout.type = SWT.HORIZONTAL;
288:                bottom_composite_layout.marginLeft = 5;
289:                bottom_composite_layout.marginTop = 5;
290:                bottom_composite_layout.marginRight = 5;
291:                bottom_composite_layout.marginBottom = 5;
292:                bottom_composite_layout.spacing = 0;
293:                bottom_composite.setLayout(bottom_composite_layout);
294:                final GridData bottom_composite_grid_data = new GridData(
295:                        GridData.FILL_HORIZONTAL);
296:                bottom_composite.setLayoutData(bottom_composite_grid_data);
297:
298:                final Button button_ok = new Button(bottom_composite, SWT.PUSH);
299:                button_ok.setText("Ok");
300:                final DialogIPOptions _this  = this ;
301:                button_ok.addSelectionListener(new SelectionListener() {
302:                    public void widgetDefaultSelected(SelectionEvent e) {
303:                        _this .tos = ctos.getSelectionIndex();
304:                        _this .port_src = port_src.getSelection();
305:                        _this .port_dst = port_dst.getSelection();
306:                        _this .pdu_max_size = packet_size.getSelection();
307:
308:                        shell.dispose();
309:                    }
310:
311:                    public void widgetSelected(SelectionEvent e) {
312:                        widgetDefaultSelected(e);
313:                    }
314:                });
315:
316:                final Button button_cancel = new Button(bottom_composite,
317:                        SWT.PUSH);
318:                button_cancel.setText(gui.getConfig().getString("cancel"));
319:                button_cancel.addSelectionListener(new SelectionListener() {
320:                    public void widgetDefaultSelected(SelectionEvent e) {
321:                        shell.dispose();
322:                    }
323:
324:                    public void widgetSelected(SelectionEvent e) {
325:                        widgetDefaultSelected(e);
326:                    }
327:                });
328:
329:                shell.pack(true);
330:                shell.open();
331:                while (!shell.isDisposed())
332:                    if (!display.readAndDispatch())
333:                        display.sleep();
334:            }
335:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.