001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id:$
023: */
024: package com.bostechcorp.cbesb.ui.util;
025:
026: import org.eclipse.swt.SWT;
027: import org.eclipse.swt.layout.FillLayout;
028: import org.eclipse.swt.layout.GridData;
029: import org.eclipse.swt.layout.GridLayout;
030: import org.eclipse.swt.widgets.Composite;
031: import org.eclipse.swt.widgets.Dialog;
032: import org.eclipse.swt.widgets.Display;
033: import org.eclipse.swt.widgets.Label;
034: import org.eclipse.swt.widgets.Shell;
035: import org.eclipse.swt.widgets.Text;
036:
037: import com.bostechcorp.cbesb.ui.util.resource.SWTResourceManager;
038:
039: /**
040: *It is a tip dialog which can pop up.It include title,description and detail.
041: */
042: public class Tip extends Dialog {
043:
044: protected Object result;
045:
046: protected Shell shell;
047:
048: private String detail = "";
049:
050: private String description = "";
051:
052: private String title = "";
053:
054: /**
055: * Create the dialog
056: * @param parent
057: * @param style
058: */
059: public Tip(Shell parent, int style) {
060: super (parent, style);
061: }
062:
063: /**
064: * Create the dialog
065: * @param parent
066: */
067: public Tip(Shell parent) {
068: this (parent, SWT.NONE);
069: }
070:
071: /**
072: * @param parent
073: * @param title
074: * @param detail
075: * @param description
076: */
077: public Tip(Shell parent, String title, String detail,
078: String description) {
079: super (parent);
080: this .title = title;
081: this .detail = detail;
082: this .description = description;
083: }
084:
085: /**
086: * Open the dialog
087: * @return the result
088: */
089: public Object open() {
090: createContents();
091: shell.open();
092: shell.layout();
093: Display display = getParent().getDisplay();
094: while (!shell.isDisposed()) {
095: if (!display.readAndDispatch())
096: display.sleep();
097: }
098: return result;
099: }
100:
101: /**
102: * Create contents of the dialog
103: */
104: protected void createContents() {
105: shell = new Shell(getParent(), SWT.DIALOG_TRIM
106: | SWT.APPLICATION_MODAL);
107: shell.setLayout(new FillLayout());
108: shell.setSize(622, 429);
109: shell.setText(title);
110:
111: GridLayout this Layout = new GridLayout();
112: Composite topLevel = new Composite(shell, SWT.NONE);
113: topLevel.setLayout(this Layout);
114: {
115: Label labelName = new Label(topLevel, SWT.NONE);
116: labelName.setFont(SWTResourceManager.getFont("", 12,
117: SWT.BOLD | SWT.ITALIC));
118: GridData label1LData = new GridData(SWT.FILL, SWT.TOP,
119: false, false);
120: label1LData.heightHint = 24;
121: labelName.setLayoutData(label1LData);
122: labelName.setText(description);
123: }
124: {
125: Text textDescription = new Text(topLevel, SWT.V_SCROLL
126: | SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.READ_ONLY);
127:
128: GridData text2LData = new GridData(SWT.FILL, SWT.FILL,
129: true, true);
130: text2LData.heightHint = 341;
131: textDescription.setText(detail);
132: textDescription.setLayoutData(text2LData);
133: }
134: }
135:
136: }
|