Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcvs2svn2004-01-30 09:09:16 -0500
committercvs2svn2004-01-30 09:09:16 -0500
commite6cd1304b8593095611bd60815d4d0bd67fe0496 (patch)
tree5b7a97a2aeed4a521f39ba74c2abe69532e6f05c
parent6ee63155d67e693147ef46438ad3ce28a3ebf7ff (diff)
downloadeclipse.platform.team-e6cd1304b8593095611bd60815d4d0bd67fe0496.tar.gz
eclipse.platform.team-e6cd1304b8593095611bd60815d4d0bd67fe0496.tar.xz
eclipse.platform.team-e6cd1304b8593095611bd60815d4d0bd67fe0496.zip
This commit was manufactured by cvs2svn to create branch
'branch_20031205_synchWorkFlowEnhancements'. Cherrypick from master 2004-01-30 14:09:15 UTC Michael Valenta <mvalenta> 'Removed unused import': bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java172
1 files changed, 172 insertions, 0 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java
new file mode 100644
index 000000000..00b16a5d8
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/KeyboardInteractiveDialog.java
@@ -0,0 +1,172 @@
+/* -*-mode:java; c-basic-offset:2; -*- */
+/**********************************************************************
+Copyright (c) 2004, Atsuhiko Yamanaka, JCraft,Inc. and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+
+Contributors:
+ Atsuhiko Yamanaka, JCraft,Inc. - initial API and implementation.
+**********************************************************************/
+package org.eclipse.team.internal.ccvs.ui;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * A dialog for keyboad-interactive authentication for the ssh2 connection.
+ */
+public class KeyboardInteractiveDialog extends Dialog {
+ // widgets
+ private Text[] texts;
+
+ protected String domain;
+ protected String destination;
+ protected String name;
+ protected String instruction;
+ protected String lang;
+ protected String[] prompt;
+ protected boolean[] echo;
+ private String message;
+ private String[] result;
+
+ /**
+ * Creates a nwe KeyboardInteractiveDialog.
+ *
+ * @param parentShell the parent shell
+ * @param destication the location
+ * @param name the name
+ * @param instruction the instruction
+ * @param prompt the titles for textfields
+ * @param echo '*' should be used or not
+ */
+ public KeyboardInteractiveDialog(Shell parentShell,
+ String location,
+ String destination,
+ String name,
+ String instruction,
+ String[] prompt,
+ boolean[] echo){
+ super(parentShell);
+ this.domain=location;
+ this.destination=destination;
+ this.name=name;
+ this.instruction=instruction;
+ this.prompt=prompt;
+ this.echo=echo;
+ this.message=Policy.bind("KeyboradInteractiveDialog.message", destination+(name!=null && name.length()>0 ? ": "+name : "")); //NON-NLS-1$
+ }
+ /**
+ * @see Window#configureShell
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ newShell.setText(message);
+ }
+ /**
+ * @see Window#create
+ */
+ public void create() {
+ super.create();
+ if(texts.length>0){
+ texts[0].setFocus();
+ }
+ }
+ /**
+ * @see Dialog#createDialogArea
+ */
+ protected Control createDialogArea(Composite parent) {
+ Composite main=new Composite(parent, SWT.NONE);
+ GridLayout layout=new GridLayout();
+ layout.numColumns=3;
+ main.setLayout(layout);
+ main.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ if (message!=null) {
+ Label messageLabel=new Label(main, SWT.WRAP);
+ messageLabel.setText(message);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan=3;
+ messageLabel.setLayoutData(data);
+ }
+ if(domain!=null){
+ Label label = new Label(main, SWT.WRAP);
+ label.setText(Policy.bind("KeyboardInteractiveDialog.labelRepository", domain));
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan=3;
+ label.setLayoutData(data);
+ }
+ if (instruction!=null && instruction.length()>0) {
+ Label messageLabel=new Label(main, SWT.WRAP);
+ messageLabel.setText(instruction);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.horizontalSpan=3;
+ messageLabel.setLayoutData(data);
+ }
+ createPasswordFields(main);
+ return main;
+ }
+ /**
+ * Creates the widgets that represent the entry area.
+ *
+ * @param parent the parent of the widgets
+ */
+ protected void createPasswordFields(Composite parent) {
+ texts=new Text[prompt.length];
+
+ for(int i=0; i<prompt.length; i++){
+ new Label(parent, SWT.NONE).setText(prompt[i]);
+ texts[i]=new Text(parent, SWT.BORDER);
+ GridData data=new GridData(GridData.FILL_HORIZONTAL);
+ data.widthHint=convertHorizontalDLUsToPixels(IDialogConstants.ENTRY_FIELD_WIDTH);
+ texts[i].setLayoutData(data);
+
+ if(!echo[i]){
+ texts[i].setEchoChar('*');
+ }
+ new Label(parent, SWT.NONE);
+ }
+
+ }
+ /**
+ * Returns the entered values, or null
+ * if the user canceled.
+ *
+ * @return the entered values
+ */
+ public String[] getResult() {
+ return result;
+ }
+ /**
+ * Notifies that the ok button of this dialog has been pressed.
+ * <p>
+ * The default implementation of this framework method sets
+ * this dialog's return code to <code>Window.OK</code>
+ * and closes the dialog. Subclasses may override.
+ * </p>
+ */
+ protected void okPressed() {
+ result=new String[prompt.length];
+ for(int i=0; i<texts.length; i++){
+ result[i]=texts[i].getText();
+ }
+ super.okPressed();
+ }
+ /**
+ * Notifies that the cancel button of this dialog has been pressed.
+ * <p>
+ * The default implementation of this framework method sets
+ * this dialog's return code to <code>Window.CANCEL</code>
+ * and closes the dialog. Subclasses may override.
+ * </p>
+ */
+ protected void cancelPressed() {
+ result=null;
+ super.cancelPressed();
+ }
+}

Back to the top