1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.javadocexport;
15 import org.eclipse.swt.events.SelectionAdapter;
16 import org.eclipse.swt.events.SelectionEvent;
17 import org.eclipse.swt.layout.GridData;
18 import org.eclipse.swt.layout.GridLayout;
19 import org.eclipse.swt.widgets.Button;
20 import org.eclipse.swt.widgets.Combo;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Control;
23 import org.eclipse.swt.widgets.DirectoryDialog;
24 import org.eclipse.swt.widgets.FileDialog;
25 import org.eclipse.swt.widgets.Label;
26 import org.eclipse.swt.widgets.Text;
28 import org.eclipse.jdt.ui.wizards.NewElementWizardPage;
30 import org.eclipse.jdt.internal.ui.util.SWTUtil;
32 public abstract class JavadocWizardPage extends NewElementWizardPage {
34 protected JavadocWizardPage(String pageName) {
36 setTitle(JavadocExportMessages.JavadocWizardPage_javadocwizardpage_description);
39 protected Button createButton(Composite composite, int style, String message, GridData gd) {
40 Button button= new Button(composite, style);
41 button.setText(message);
42 button.setLayoutData(gd);
46 protected GridLayout createGridLayout(int columns) {
47 return new GridLayout(columns, false);
51 protected GridData createGridData(int flag, int hspan, int vspan, int indent) {
52 GridData gd= new GridData(flag);
53 gd.horizontalIndent= indent;
54 gd.horizontalSpan= hspan;
55 gd.verticalSpan= vspan;
59 protected GridData createGridData(int flag, int hspan, int indent) {
60 GridData gd= new GridData(flag);
61 gd.horizontalIndent= indent;
62 gd.horizontalSpan= hspan;
66 protected GridData createGridData(int hspan) {
67 GridData gd= new GridData();
68 gd.horizontalSpan= hspan;
72 protected Label createLabel(Composite composite, int style, String message, GridData gd) {
73 Label label= new Label(composite, style);
74 label.setText(message);
75 label.setLayoutData(gd);
79 protected Text createText(Composite composite, int style, String message, GridData gd) {
80 Text text= new Text(composite, style);
82 text.setText(message);
83 text.setLayoutData(gd);
87 protected Combo createCombo(Composite composite, int style, String message, GridData gd) {
88 Combo combo= new Combo(composite, style);
89 SWTUtil.setDefaultVisibleItemCount(combo);
91 combo.setText(message);
92 combo.setLayoutData(gd);
96 protected void handleFileBrowseButtonPressed(Text text, String[] extensions, String title) {
97 FileDialog dialog= new FileDialog(text.getShell());
98 dialog.setText(title);
99 dialog.setFilterExtensions(extensions);
100 String dirName= text.getText();
101 if (!dirName.equals("")) { //$NON-NLS-1$
102 File path= new File(dirName);
104 dialog.setFilterPath(dirName);
107 String selectedDirectory= dialog.open();
108 if (selectedDirectory != null)
109 text.setText(selectedDirectory);
112 protected String handleFolderBrowseButtonPressed(String dir, String title, String message) {
113 DirectoryDialog dialog= new DirectoryDialog(getShell());
114 dialog.setFilterPath(dir);
115 dialog.setText(title);
116 dialog.setMessage(message);
117 String res= dialog.open();
119 File file= new File(res);
120 if (file.isDirectory())
126 protected static class EnableSelectionAdapter extends SelectionAdapter {
127 private Control[] fEnable;
128 private Control[] fDisable;
130 protected EnableSelectionAdapter(Control[] enable, Control[] disable) {
137 public void widgetSelected(SelectionEvent e) {
138 for (int i= 0; i < fEnable.length; i++) {
139 fEnable[i].setEnabled(true);
141 for (int i= 0; i < fDisable.length; i++) {
142 fDisable[i].setEnabled(false);
146 //copied from WizardNewProjectCreationPage
147 public void validate() {
150 } //end class EnableSelectionAdapter
152 protected static class ToggleSelectionAdapter extends SelectionAdapter {
155 protected ToggleSelectionAdapter(Control[] controls) {
156 this.controls= controls;
160 public void widgetSelected(SelectionEvent e) {
162 for (int i= 0; i < controls.length; i++) {
163 Control control= controls[i];
164 control.setEnabled(!control.getEnabled());
169 public void validate() {
172 } //end class ToggleSelection Adapter