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:
025: package com.bostechcorp.cbesb.ui.ide.security;
026:
027: import org.eclipse.swt.SWT;
028: import org.eclipse.swt.events.SelectionAdapter;
029: import org.eclipse.swt.events.SelectionEvent;
030: import org.eclipse.swt.events.SelectionListener;
031:
032: import org.eclipse.swt.layout.GridData;
033: import org.eclipse.swt.layout.GridLayout;
034: import org.eclipse.swt.widgets.Button;
035: import org.eclipse.swt.widgets.Composite;
036: import org.eclipse.swt.widgets.Group;
037: import org.eclipse.swt.widgets.Label;
038:
039: public class CMWTextComposite extends Composite {
040: /**
041: * Create the template composite .
042: * This class is basically used in some Security Wizard pages,
043: * because of simailar context. This composite provides only a
044: * Label, and a goupbox with 2 radio buttons for question/answer
045: *
046: * @param parent
047: * @param style
048: */
049:
050: private Button yesButton;
051: private Button noButton;
052: private boolean radioVisible = false;
053: private boolean isYes = true;
054:
055: public CMWTextComposite(Composite parent, int style,
056: String labelText) {
057: super (parent, style);
058: createContents(labelText, "", "", "", false);
059: //
060: }
061:
062: public CMWTextComposite(Composite parent, int style,
063: String labelText, String group, String yes, String no) {
064: super (parent, style);
065: createContents(labelText, group, yes, no, true);
066: //
067: }
068:
069: @Override
070: public void dispose() {
071: super .dispose();
072: }
073:
074: @Override
075: protected void checkSubclass() {
076: // Disable the check that prevents subclassing of SWT components
077: }
078:
079: protected void createContents(String labelText, String groupText,
080: String yes, String no, boolean r) {
081: radioVisible = r;
082: this .setLayout(new GridLayout());
083: final Label label = new Label(this , SWT.BORDER | SWT.WRAP);
084: label
085: .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
086: true));
087: label.setText(labelText);
088: final Group importCertificateIntoGroup = new Group(this ,
089: SWT.NONE);
090: importCertificateIntoGroup.setLayoutData(new GridData(SWT.FILL,
091: SWT.CENTER, true, false));
092: importCertificateIntoGroup.setText(groupText);
093: importCertificateIntoGroup.setLayout(new GridLayout());
094:
095: importCertificateIntoGroup.setVisible(radioVisible);
096:
097: yesButton = new Button(importCertificateIntoGroup, SWT.RADIO);
098: yesButton.setSelection(true);
099:
100: yesButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
101: true, false));
102: yesButton.setText(yes);
103:
104: noButton = new Button(importCertificateIntoGroup, SWT.RADIO);
105:
106: noButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
107: false));
108: noButton.setText(no);
109:
110: yesButton.addSelectionListener(new SelectionAdapter() {
111: public void widgetSelected(final SelectionEvent e) {
112: isYes = true;
113: }
114:
115: public void widgetDefaultSelected(final SelectionEvent e) {
116: isYes = true;
117: }
118: });
119:
120: noButton.addSelectionListener(new SelectionAdapter() {
121: public void widgetSelected(final SelectionEvent e) {
122: isYes = false;
123: }
124: });
125:
126: }
127:
128: public boolean isYes() {
129: return isYes;
130: }
131:
132: public void addSelectionListener(SelectionAdapter listener) {
133: yesButton.addSelectionListener(listener);
134: noButton.addSelectionListener(listener);
135: }
136: }
|