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.componentflow.componentFlowEditor.diagram.wizards;
025:
026: import java.util.Map;
027:
028: import org.eclipse.jface.dialogs.Dialog;
029: import org.eclipse.jface.dialogs.IDialogConstants;
030: import org.eclipse.swt.SWT;
031: import org.eclipse.swt.events.SelectionAdapter;
032: import org.eclipse.swt.events.SelectionEvent;
033: import org.eclipse.swt.graphics.Point;
034: import org.eclipse.swt.layout.GridData;
035: import org.eclipse.swt.layout.GridLayout;
036: import org.eclipse.swt.widgets.Button;
037: import org.eclipse.swt.widgets.Combo;
038: import org.eclipse.swt.widgets.Composite;
039: import org.eclipse.swt.widgets.Control;
040: import org.eclipse.swt.widgets.Label;
041: import org.eclipse.swt.widgets.Shell;
042: import org.eclipse.swt.widgets.Text;
043: import org.eclipse.ui.PlatformUI;
044: import org.eclipse.ui.part.FileEditorInput;
045:
046: import com.bostechcorp.cbesb.common.i18n.I18N;
047: import com.bostechcorp.cbesb.common.i18n.Messages;
048: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.part.ComponentFlowEditorDiagramEditorPlugin;
049: import com.bostechcorp.cbesb.ui.util.browser.BaseFileBrowser;
050:
051: public class HttpAuthenticationDialog extends Dialog {
052:
053: private Combo modeCombo;
054: private Text userText;
055: private Text passwordText;
056: private Map<String, String> authenticationMap;
057:
058: private boolean updateOperation = false;
059:
060: protected HttpAuthenticationDialog(Shell parentShell,
061: Map<String, String> sslMap, boolean updateOperation) {
062: super (parentShell);
063: this .authenticationMap = sslMap;
064: this .updateOperation = updateOperation;
065: }
066:
067: protected Control createDialogArea(Composite parent) {
068: Composite container = (Composite) super
069: .createDialogArea(parent);
070: final GridLayout gridLayout = new GridLayout();
071: gridLayout.verticalSpacing = 10;
072: gridLayout.marginTop = 10;
073: gridLayout.numColumns = 2;
074: gridLayout.horizontalSpacing = 10;
075: container.setLayout(gridLayout);
076:
077: final Label proxyHostLabel = new Label(container, SWT.NONE);
078: proxyHostLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
079: false, false));
080: proxyHostLabel.setText("Mode");
081:
082: modeCombo = new Combo(container, SWT.READ_ONLY);
083: modeCombo.setItems(new String[] { "Basic" });
084: modeCombo.select(0);
085: modeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
086: true, false));
087:
088: final Label userLabel = new Label(container, SWT.NONE);
089: userLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
090: false, false));
091: userLabel.setText("User");
092:
093: userText = new Text(container, SWT.BORDER);
094: userText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
095: false));
096:
097: final Label passwordLabel = new Label(container, SWT.NONE);
098: passwordLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
099: false, false));
100: passwordLabel.setText("Password");
101:
102: passwordText = new Text(container, SWT.PASSWORD | SWT.BORDER);
103: passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
104: true, false));
105:
106: if (updateOperation || authenticationMap.size() != 0) {
107: modelsToControl();
108: }
109:
110: return container;
111: }
112:
113: private void modelsToControl() {
114: if (authenticationMap.get("user") != null
115: && !"".equals(authenticationMap.get("user"))) {
116: userText.setText(authenticationMap.get("user"));
117: } else {
118: userText.setText("");
119: }
120:
121: if (authenticationMap.get("password") != null
122: && !"".equals(authenticationMap.get("password"))) {
123: passwordText.setText(authenticationMap.get("password"));
124: } else {
125: passwordText.setText("");
126: }
127: }
128:
129: private void controlToModels() {
130: authenticationMap.put("user", userText.getText());
131: authenticationMap.put("password", passwordText.getText());
132: }
133:
134: protected void okPressed() {
135: controlToModels();
136: super .okPressed();
137: }
138:
139: @Override
140: protected void cancelPressed() {
141: super .cancelPressed();
142: }
143:
144: /**
145: * Create contents of the button bar
146: *
147: * @param parent
148: */
149: @Override
150: protected void createButtonsForButtonBar(Composite parent) {
151: createButton(parent, IDialogConstants.OK_ID,
152: IDialogConstants.OK_LABEL, true);
153: createButton(parent, IDialogConstants.CANCEL_ID,
154: IDialogConstants.CANCEL_LABEL, false);
155: }
156:
157: /**
158: * Return the initial size of the dialog
159: */
160: @Override
161: protected Point getInitialSize() {
162: return new Point(372, 240);
163: }
164:
165: protected void configureShell(Shell newShell) {
166: super .configureShell(newShell);
167: newShell.setText("Authentication Dialog");
168: }
169: }
|