Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2008 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 package org.eclipse.equinox.internal.security.ui.storage;
 
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.events.ModifyEvent;
 import  org.eclipse.swt.events.ModifyListener;
 import  org.eclipse.swt.layout.GridData;
 import  org.eclipse.swt.layout.GridLayout;
 import  org.eclipse.swt.widgets.*;
 
 public class ChallengeResponseDialog extends TitleAreaDialog {
 
 	private static final String HELP_ID = "org.eclipse.equinox.security.ui.challenge_response_dialog"//$NON-NLS-1$
 
 	protected Text[] questions;
 	protected Text[] answers;
 
 	protected String[] questionsText = null;
 	protected String[] answersText = null;
 
 	protected Button okButton;
 	final protected int size;
 
 	public ChallengeResponseDialog(int numberOfQuestions, Shell parentShell) {
 		super(parentShell);
 		this. = numberOfQuestions;
 		 = new Text[this.];
 		 = new Text[this.];
 	}
 
 	protected void configureShell(Shell shell) {
 		super.configureShell(shell);
 		PlatformUI.getWorkbench().getHelpSystem().setHelp(shell);
 	}
 
 	protected void createButtonsForButtonBar(Composite parent) {
 		.setEnabled(false);
 	}
 
 	protected boolean isResizable() {
 		return true;
 	}
 
 	protected Control createDialogArea(Composite parent) {
 		Composite compositeTop = (Composite) super.createDialogArea(parent);
 
 		Composite composite = new Composite(compositeTop, SWT.NONE);
 
 
 		Label storyLabel = new Label(composite, SWT.WRAP);
 		GridData labelData = new GridData(SWT.FILL, SWT.BEGINNING, truefalse);
 		labelData.widthHint = 500;
 		storyLabel.setLayoutData(labelData);
 		storyLabel.setText(.);
 
 		for (int i = 0; i < i++) {
 			Group group = new Group(composite, SWT.NONE);
 			group.setText(NLS.bind(., Integer.toString(i + 1)));
 			group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, truefalse));
 			group.setLayout(new GridLayout(2, false));
 
 			new Label(group, SWT.LEFT).setText(.);
 			[i] = new Text(group, SWT.LEFT | SWT.BORDER);
 			[i].setLayoutData(new GridData(GridData.FILL, GridData.FILL, truefalse));
 			[i].addModifyListener(new ModifyListener() {
 				public void modifyText(ModifyEvent event) {
 				}
 			});
 
 			new Label(group, SWT.LEFT).setText(.);
 			[i] = new Text(group, SWT.LEFT | SWT.BORDER);
 			[i].setLayoutData(new GridData(GridData.FILL, GridData.FILL, truefalse));
 			[i].addModifyListener(new ModifyListener() {
 				public void modifyText(ModifyEvent event) {
 				}
 			});
 		}
 
		composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, truetrue));
		GridLayoutFactory.swtDefaults().generateLayout(composite);
		return composite;
	}
	protected void validateOK() {
		boolean valid = true;
		for (int i = 0; i < i++) {
			if ([i] == null)
				continue;
			String question = [i].getText();
			if (question == null || question.length() == 0) {
				valid = false;
				break;
			}
			if ([i] == null)
				continue;
			String answer = [i].getText();
			if (answer == null || answer.length() == 0) {
				valid = false;
				break;
			}
		}
		if (valid)
		else
		.setEnabled(valid);
	}
	protected void okPressed() {
		for (int i = 0; i < i++) {
			[i] = [i].getText();
			[i] = [i].getText();
		}
		super.okPressed();
	}
	public String[][] getResult() {
		if ( == null ||  == null)
			return null;
		return new String[][] {};
	}
New to GrepCode? Check out our FAQ X