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 HttpProxyWizard extends Dialog {
052:
053: private Text userText;
054: private Text passwordText;
055: private Text portText;
056: private Text hostText;
057: private Map<String, String> proxyMap;
058:
059: private boolean updateOperation = false;
060:
061: protected HttpProxyWizard(Shell parentShell,
062: Map<String, String> sslMap, boolean updateOperation) {
063: super (parentShell);
064: this .proxyMap = sslMap;
065: this .updateOperation = updateOperation;
066: }
067:
068: protected Control createDialogArea(Composite parent) {
069: Composite container = (Composite) super
070: .createDialogArea(parent);
071: final GridLayout gridLayout = new GridLayout();
072: gridLayout.verticalSpacing = 10;
073: gridLayout.marginTop = 10;
074: gridLayout.numColumns = 2;
075: gridLayout.horizontalSpacing = 10;
076: container.setLayout(gridLayout);
077:
078: final Label proxyHostLabel = new Label(container, SWT.NONE);
079: proxyHostLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
080: false, false));
081: proxyHostLabel.setText(I18N.getString(Messages.PROXY_HOST));
082:
083: hostText = new Text(container, SWT.BORDER);
084: hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
085: false));
086:
087: final Label proxyPortLabel = new Label(container, SWT.NONE);
088: proxyPortLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
089: false, false));
090: proxyPortLabel.setText(I18N.getString(Messages.PROXY_PORT));
091:
092: portText = new Text(container, SWT.BORDER);
093: portText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
094: false));
095:
096: final Label userLabel = new Label(container, SWT.NONE);
097: userLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
098: false, false));
099: userLabel.setText(I18N.getString(Messages.PROXY_USER));
100:
101: userText = new Text(container, SWT.BORDER);
102: userText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
103: false));
104:
105: final Label passwordLabel = new Label(container, SWT.NONE);
106: passwordLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
107: false, false));
108: passwordLabel.setText(I18N.getString(Messages.PROXY_PASSWORD));
109:
110: passwordText = new Text(container, SWT.PASSWORD | SWT.BORDER);
111: passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
112: true, false));
113:
114: if (updateOperation || proxyMap.size() != 0) {
115: modelsToControl();
116: }
117:
118: return container;
119: }
120:
121: private void modelsToControl() {
122: if (proxyMap.get("host") != null
123: && !"".equals(proxyMap.get("host"))) {
124: hostText.setText(proxyMap.get("host"));
125: } else {
126: hostText.setText("");
127: }
128:
129: if (proxyMap.get("port") != null
130: && !"".equals(proxyMap.get("port"))) {
131: portText.setText(proxyMap.get("port"));
132: } else {
133: portText.setText("");
134: }
135:
136: if (proxyMap.get("user") != null
137: && !"".equals(proxyMap.get("user"))) {
138: userText.setText(proxyMap.get("user"));
139: } else {
140: userText.setText("");
141: }
142:
143: if (proxyMap.get("password") != null
144: && !"".equals(proxyMap.get("password"))) {
145: passwordText.setText(proxyMap.get("password"));
146: } else {
147: passwordText.setText("");
148: }
149: }
150:
151: private void controlToModels() {
152: proxyMap.put("host", hostText.getText());
153: proxyMap.put("port", portText.getText());
154: proxyMap.put("user", userText.getText());
155: proxyMap.put("password", passwordText.getText());
156: }
157:
158: protected void okPressed() {
159: controlToModels();
160: super .okPressed();
161: }
162:
163: @Override
164: protected void cancelPressed() {
165: super .cancelPressed();
166: }
167:
168: /**
169: * Create contents of the button bar
170: *
171: * @param parent
172: */
173: @Override
174: protected void createButtonsForButtonBar(Composite parent) {
175: createButton(parent, IDialogConstants.OK_ID,
176: IDialogConstants.OK_LABEL, true);
177: createButton(parent, IDialogConstants.CANCEL_ID,
178: IDialogConstants.CANCEL_LABEL, false);
179: }
180:
181: /**
182: * Return the initial size of the dialog
183: */
184: @Override
185: protected Point getInitialSize() {
186: return new Point(391, 276);
187: }
188:
189: protected void configureShell(Shell newShell) {
190: super.configureShell(newShell);
191: newShell.setText(I18N.getString(Messages.PROXY_DIALOG));
192: }
193: }
|