/* * Created on 12-jul-2003 * */ package com.quantum.view.bookmark; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.Vector; import com.quantum.IQuantumConstants; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.help.WorkbenchHelp; /** * @author panic * */ public class AddSchemaDialog extends Dialog { protected Vector input; protected List list; private Vector selection; /** * Creates a new AddSchemaDialog. */ public AddSchemaDialog(Shell parentShell, Vector input) { super(parentShell); this.input = input; this.list = null; selection = null; } /* (non-Javadoc) * Method declared on Window. */ protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText("Set Schemas"); WorkbenchHelp.setHelp( newShell, IQuantumConstants.ADD_SCHEMA_DIALOG_CONTEXT); } /* (non-Javadoc) * Method declared on Dialog */ protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); list = new List(composite, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); GridData data = new GridData(GridData.FILL_BOTH); list.setLayoutData(data); for (Iterator iter = input.iterator(); iter.hasNext();) { String element = (String) iter.next(); list.add(element); } return composite; } /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#okPressed() */ protected void okPressed() { // If it's OK, then the selection is not null. Null is used to signal a canceled dialog. selection = new Vector(); if (list != null) { String selecStr[] = list.getSelection(); for (int i = 0; i < selecStr.length; i++) { String string = selecStr[i]; selection.add(string); } } super.okPressed(); } public Collection getSelectedSchemas() { return this.selection == null ? null : new ArrayList(this.selection); } }