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 org.apache.commons.logging.Log;
026: import org.apache.commons.logging.LogFactory;
027:
028: import org.eclipse.swt.*;
029: import org.eclipse.swt.widgets.*;
030: import org.eclipse.swt.layout.*;
031: import org.eclipse.swt.custom.*;
032: import org.eclipse.swt.events.*;
033: import org.eclipse.swt.graphics.*;
034: import org.eclipse.swt.browser.*;
035:
036: /**
037: * This class displays the "about" dialog.
038: * @author Alexandre Fenyo
039: * @version $Id: DialogAbout.java,v 1.6 2007/03/03 00:38:19 fenyo Exp $
040: */
041:
042: public class DialogAbout extends Dialog {
043: private static Log log = LogFactory.getLog(DialogAbout.class);
044:
045: private GridLayout layout = null;
046: private Composite groups_composite = null;
047: private Composite bottom_composite = null;
048: private RowLayout groups_composite_layout = null;
049: private RowLayout bottom_composite_layout = null;
050: private GridData groups_composite_grid_data = null;
051: private Label label_image = null;
052: private GUI gui;
053:
054: /**
055: * Constructor.
056: * @param gui current GUI instance.
057: * @param parent parent shell.
058: */
059: public DialogAbout(final GUI gui, final Shell parent) {
060: super (parent, 0);
061: this .gui = gui;
062: }
063:
064: /**
065: * Displays the dialog.
066: * @param none.
067: * @return void.
068: */
069: public void open() {
070: final Shell parent = getParent();
071: final Display display = parent.getDisplay();
072: final Shell shell = new Shell(parent, SWT.TITLE | SWT.BORDER
073: | SWT.APPLICATION_MODAL);
074: shell.setText("GNetWatch - About");
075:
076: // Your code goes here (widget creation, set result, etc).
077: // Composite for groups at left
078: layout = new GridLayout();
079: layout.numColumns = 1;
080: layout.marginHeight = 2;
081: layout.marginWidth = 2;
082: layout.verticalSpacing = 1;
083: shell.setLayout(layout);
084:
085: groups_composite = new Composite(shell, SWT.FLAT);
086: groups_composite_layout = new RowLayout(SWT.VERTICAL);
087: groups_composite_layout.fill = true;
088: groups_composite_layout.marginTop = 0;
089: groups_composite_layout.marginBottom = 0;
090: groups_composite.setLayout(groups_composite_layout);
091: groups_composite_grid_data = new GridData(
092: GridData.FILL_VERTICAL);
093: groups_composite.setLayoutData(groups_composite_grid_data);
094:
095: // Group for network parameters
096:
097: label_image = new Label(groups_composite, SWT.SHADOW_ETCHED_IN
098: | SWT.BORDER);
099: label_image.setText("Network parameters");
100: label_image.setImage(new Image(display, "pictures/about.png"));
101:
102: // bottom buttons
103:
104: bottom_composite = new Composite(shell, SWT.FLAT);
105: bottom_composite_layout = new RowLayout();
106: bottom_composite_layout.fill = true;
107: bottom_composite_layout.marginTop = 0;
108: bottom_composite_layout.marginBottom = 0;
109: bottom_composite_layout.wrap = false;
110: bottom_composite_layout.pack = false;
111: bottom_composite_layout.justify = true;
112: bottom_composite_layout.type = SWT.HORIZONTAL;
113: bottom_composite_layout.marginLeft = 5;
114: bottom_composite_layout.marginTop = 5;
115: bottom_composite_layout.marginRight = 5;
116: bottom_composite_layout.marginBottom = 5;
117: bottom_composite_layout.spacing = 0;
118: bottom_composite.setLayout(bottom_composite_layout);
119: final GridData bottom_composite_grid_data = new GridData(
120: GridData.FILL_HORIZONTAL);
121: bottom_composite.setLayoutData(bottom_composite_grid_data);
122:
123: final Button button_ok = new Button(bottom_composite, SWT.PUSH);
124: button_ok.setText(gui.getConfig().getString("license"));
125:
126: button_ok.addSelectionListener(new SelectionListener() {
127: public void widgetDefaultSelected(SelectionEvent e) {
128: shell.dispose();
129: }
130:
131: public void widgetSelected(SelectionEvent e) {
132: widgetDefaultSelected(e);
133: }
134: });
135:
136: shell.pack(true);
137: shell.open();
138: while (!shell.isDisposed())
139: if (!display.readAndDispatch())
140: display.sleep();
141: }
142: }
|