blob: 7ee3f15fe56c9e5d887d2105c56d58b222c50bb3 [file] [log] [blame]
package org.eclipse.team.internal.ccvs.ui.wizards;
/*
* (c) Copyright IBM Corp. 2000, 2001.
* All Rights Reserved.
*/
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.team.internal.ccvs.ui.*;
/**
* Common superclass for CVS wizard pages. Provides convenience methods
* for widget creation.
*/
public abstract class CVSWizardPage extends WizardPage {
/**
* CVSWizardPage constructor comment.
* @param pageName the name of the page
*/
public CVSWizardPage(String pageName) {
super(pageName);
}
/**
* CVSWizardPage constructor comment.
* @param pageName the name of the page
* @param title the title of the page
* @param titleImage the image for the page
*/
public CVSWizardPage(String pageName, String title, ImageDescriptor titleImage) {
super(pageName, title, titleImage);
}
/**
* Creates a new checkbox instance and sets the default layout data.
*
* @param group the composite in which to create the checkbox
* @param label the string to set into the checkbox
* @return the new checkbox
*/
protected Button createCheckBox(Composite group, String label) {
Button button = new Button(group, SWT.CHECK | SWT.LEFT);
button.setText(label);
GridData data = new GridData();
data.horizontalSpan = 2;
button.setLayoutData(data);
return button;
}
/**
* Utility method that creates a combo box
*
* @param parent the parent for the new label
* @return the new widget
*/
protected Combo createCombo(Composite parent) {
Combo combo = new Combo(parent, SWT.READ_ONLY);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
combo.setLayoutData(data);
return combo;
}
/**
* Creates composite control and sets the default layout data.
*
* @param parent the parent of the new composite
* @param numColumns the number of columns for the new composite
* @return the newly-created coposite
*/
protected Composite createComposite(Composite parent, int numColumns) {
Composite composite = new Composite(parent, SWT.NULL);
// GridLayout
GridLayout layout = new GridLayout();
layout.numColumns = numColumns;
composite.setLayout(layout);
// GridData
GridData data = new GridData();
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
composite.setLayoutData(data);
return composite;
}
/**
* Utility method that creates a label instance
* and sets the default layout data.
*
* @param parent the parent for the new label
* @param text the text for the new label
* @return the new label
*/
protected Label createLabel(Composite parent, String text) {
Label label = new Label(parent, SWT.LEFT);
label.setText(text);
GridData data = new GridData();
data.horizontalSpan = 1;
data.horizontalAlignment = GridData.FILL;
label.setLayoutData(data);
return label;
}
/**
* Create a text field specific for this application
*
* @param parent the parent of the new text field
* @return the new text field
*/
protected Text createTextField(Composite parent) {
Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
GridData data = new GridData(GridData.FILL_HORIZONTAL);
data.verticalAlignment = GridData.CENTER;
data.grabExcessVerticalSpace = false;
data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH;
text.setLayoutData(data);
return text;
}
/**
* Utility method to create a radio button
*
* @param parent the parent of the radio button
* @param label the label of the radio button
* @param span the number of columns to span
* @return the created radio button
*/
protected Button createRadioButton(Composite parent, String label, int span) {
Button button = new Button(parent, SWT.RADIO);
button.setText(label);
GridData data = new GridData();
data.horizontalSpan = span;
button.setLayoutData(data);
return button;
}
}